FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY Directory.Packages.props ./

COPY Apis/rag-api/rag-api.csproj Apis/rag-api/
COPY Apis/rag-data/rag-data.csproj Apis/rag-data/
COPY Apis/common/common.csproj Apis/common/
COPY Apis/rag-api-models/rag-api-models.csproj Apis/rag-api-models/
COPY Apis/shared-data/shared-data.csproj Apis/shared-data/
COPY Helpers/common-helpers/common-helpers.csproj Helpers/common-helpers/
COPY Helpers/startup-helpers/startup-helpers.csproj Helpers/startup-helpers/

RUN dotnet restore Apis/rag-api/rag-api.csproj

COPY Apis/rag-api/ Apis/rag-api/
COPY Apis/rag-data/ Apis/rag-data/
COPY Apis/common/ Apis/common/
COPY Apis/rag-api-models/ Apis/rag-api-models/
COPY Apis/shared-data/ Apis/shared-data/
COPY Helpers/common-helpers/ Helpers/common-helpers/
COPY Helpers/startup-helpers/ Helpers/startup-helpers/

RUN dotnet publish Apis/rag-api/rag-api.csproj -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
WORKDIR /app
EXPOSE 8080
ENV ASPNETCORE_URLS=http://0.0.0.0:8080

COPY --from=build /app/publish .

ENTRYPOINT ["dotnet", "rag-api.dll"]
