From 6fea7dee1ce44fa5f432a254104e892c71cc4e24 Mon Sep 17 00:00:00 2001 From: Xander Sigler Date: Sat, 31 Dec 2022 00:41:52 -0800 Subject: [PATCH] Corrected the .dockerfile to use the correct build image --- AdventOfCode/Dockerfile | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/AdventOfCode/Dockerfile b/AdventOfCode/Dockerfile index ddaf901..cd2097c 100644 --- a/AdventOfCode/Dockerfile +++ b/AdventOfCode/Dockerfile @@ -1,27 +1,18 @@ -FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build -WORKDIR /src -COPY . ./ -RUN dotnet restore - -#COPY ["/src/AdventOfCode/AdventOfCode.csproj", "AdventOfCode/"] -RUN dotnet restore "AdventOfCode.csproj" -#COPY ["AdventOfCode/", "AdventOfCode/."] - +# Copy csproj and restore as distinct layers -RUN dotnet build "AdventOfCode.csproj" -c Release -o /app/build +COPY . ./ +RUN dotnet publish -c Release -o out -FROM build AS publish -RUN dotnet publish "./AdventOfCode.csproj" -c Release -o /app/publish -FROM base AS final +FROM mcr.microsoft.com/dotnet/aspnet:5.0 WORKDIR /app - +COPY --from=build-env /app/out . ENV ASPNETCORE_ENVIRONMENT=Production ENV ASPNETCORE_URLS=http://+:80 -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "AdventOfCode.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "AdventOfCode.dll"] +