From bb3f52b2656cdcc54dcacba43528c6194a8901e7 Mon Sep 17 00:00:00 2001 From: Mathias Beaulieu-Duncan Date: Tue, 3 Feb 2026 17:17:44 -0500 Subject: [PATCH] Strip unused SDK components to reduce image size Remove templates, TestHostNetFramework, and DotnetTools from SDK image. These are not needed for dotnet restore/build/publish and save ~124 MB. Co-Authored-By: Claude Opus 4.5 --- dockerfiles/sdk.Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dockerfiles/sdk.Dockerfile b/dockerfiles/sdk.Dockerfile index 75b7790..99f1220 100644 --- a/dockerfiles/sdk.Dockerfile +++ b/dockerfiles/sdk.Dockerfile @@ -2,6 +2,10 @@ FROM scratch ARG TARGETARCH ADD build-${TARGETARCH}/sdk/rootfs.tar.gz / COPY dotnet-${TARGETARCH}/sdk/ /usr/share/dotnet/ +# Strip components not needed for building +RUN rm -rf /usr/share/dotnet/templates \ + /usr/share/dotnet/sdk/*/TestHostNetFramework \ + /usr/share/dotnet/sdk/*/DotnetTools ENV DOTNET_ROOT=/usr/share/dotnet ENV PATH="/usr/share/dotnet:${PATH}" ENV DOTNET_RUNNING_IN_CONTAINER=true