Skip to content

Instantly share code, notes, and snippets.

@kjhickman
kjhickman / Dockerfile
Created April 8, 2022 05:42
Dockerfile for a small .NET 6 image, about 1/4 the size of the image made by the Visual Studio-generated Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS publish
WORKDIR /src
COPY SampleProject.csproj ./
RUN dotnet restore "./SampleProject.csproj" --runtime alpine-x64
COPY . .
RUN dotnet publish "SampleProject.csproj" -c Release -o /app/publish \
--no-restore \
--runtime alpine-x64 \
--self-contained true \
/p:PublishTrimmed=true \