From 108ff834cfb8e974ca5da2597d308e72e8e495df Mon Sep 17 00:00:00 2001 From: Adam Leskis Date: Sun, 8 Sep 2024 15:07:47 +0100 Subject: [PATCH] slim down the final container image --- Huxley2/Dockerfile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Huxley2/Dockerfile b/Huxley2/Dockerfile index 06119e7..1f41c3c 100644 --- a/Huxley2/Dockerfile +++ b/Huxley2/Dockerfile @@ -3,14 +3,20 @@ WORKDIR /app # Copy csproj and restore as distinct layers COPY *.csproj ./ -RUN dotnet restore +RUN dotnet restore --runtime alpine-x64 # Copy everything else and build COPY . ./ -RUN dotnet publish -c Release -o out +RUN dotnet publish -c Release -o out \ + --no-restore \ + --runtime alpine-x64 \ + --self-contained true \ + /p:PublishTrimmed=true \ + /p:PublishSingleFile=true + # Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:6.0 +FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine WORKDIR /app COPY --from=build-env /app/out . -ENTRYPOINT ["dotnet", "Huxley2.dll"] +ENTRYPOINT ["./Huxley2"]