Strip unused SDK components to reduce image size
Some checks failed
Build and Push .NET Images / discover (release) Successful in 1s
Build and Push .NET Images / build (release) Failing after 9m35s

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 <noreply@anthropic.com>
This commit is contained in:
Mathias Beaulieu-Duncan 2026-02-03 17:17:44 -05:00
parent a677ab6d9d
commit bb3f52b265

View File

@ -2,6 +2,10 @@ FROM scratch
ARG TARGETARCH ARG TARGETARCH
ADD build-${TARGETARCH}/sdk/rootfs.tar.gz / ADD build-${TARGETARCH}/sdk/rootfs.tar.gz /
COPY dotnet-${TARGETARCH}/sdk/ /usr/share/dotnet/ 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 DOTNET_ROOT=/usr/share/dotnet
ENV PATH="/usr/share/dotnet:${PATH}" ENV PATH="/usr/share/dotnet:${PATH}"
ENV DOTNET_RUNNING_IN_CONTAINER=true ENV DOTNET_RUNNING_IN_CONTAINER=true