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

COPY Jobs/cv-cleanup-job/cv-cleanup-job.csproj Jobs/cv-cleanup-job/
COPY Jobs/job-scheduler/job-scheduler.csproj Jobs/job-scheduler/
COPY Helpers/startup-helpers/startup-helpers.csproj Helpers/startup-helpers/
COPY Apis/api-models/api-models.csproj Apis/api-models/
COPY Apis/common/common.csproj Apis/common/

RUN dotnet restore Jobs/cv-cleanup-job/cv-cleanup-job.csproj

COPY Jobs/cv-cleanup-job/ Jobs/cv-cleanup-job/
COPY Jobs/job-scheduler/ Jobs/job-scheduler/
COPY Helpers/startup-helpers/ Helpers/startup-helpers/
COPY Apis/api-models/ Apis/api-models/
COPY Apis/common/ Apis/common/

RUN dotnet publish Jobs/cv-cleanup-job/cv-cleanup-job.csproj -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
WORKDIR /app

COPY --from=build /app/publish .

ENTRYPOINT ["dotnet", "cv-cleanup-job.dll"]
