ARG BUILD_REVISION=development

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_REVISION
WORKDIR /src

COPY ["api/QuestionsApi/QuestionsApi.csproj", "api/QuestionsApi/"]
RUN dotnet restore "api/QuestionsApi/QuestionsApi.csproj"

COPY api/QuestionsApi/ api/QuestionsApi/
COPY content/dynamic_questions/ content/dynamic_questions/
WORKDIR /src/api/QuestionsApi
RUN dotnet publish "QuestionsApi.csproj" -c Release -o /app/publish /p:UseAppHost=false /p:SourceRevisionId=${BUILD_REVISION}

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
ARG BUILD_REVISION
WORKDIR /app
COPY --from=build /app/publish .
COPY --from=build /src/content/dynamic_questions ./content/dynamic_questions

ENV ASPNETCORE_URLS=http://+:5008 \
    ASPNETCORE_ENVIRONMENT=Production \
    Deployment__BuildRevision=${BUILD_REVISION}

EXPOSE 5008

ENTRYPOINT ["dotnet", "QuestionsApi.dll"]
