FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env WORKDIR /app EXPOSE 5001 # Copy csproj and restore as distinct layers COPY src/PIT.ReservationService/PIT.ReservationService.csproj ./ COPY src/PIT.ReservationService/nuget.config ./ RUN dotnet restore # Copy everything else and build COPY src/PIT.ReservationService ./ RUN dotnet publish -c Release -o out # Build runtime image FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 WORKDIR /app COPY --from=build-env /app/out . ENTRYPOINT ["dotnet", "PIT.ReservationService.dll", "--environment=Production"] RUN apt-get update \ && apt-get install -y apt-transport-https \ && apt-get upgrade -y \ && apt-get autoremove -y \ && apt-get clean \ && rm -rf /var/cache/apt/archives