Skip to content

Commit bed901f

Browse files
slim NuGet cache (#313)
1 parent b741779 commit bed901f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ RUN dotnet restore -a $TARGETARCH
3636
COPY src/Exercism.TestRunner.CSharp/ ./
3737
RUN dotnet publish -a $TARGETARCH --output /opt/test-runner --no-restore
3838

39+
# Slim the pre-installed NuGet cache before it is copied into the runtime image.
40+
# Restore from the global packages folder uses the extracted files, so the .nupkg
41+
# archives, foreign-platform Capstone natives (a BenchmarkDotNet disassembly
42+
# dependency) and the build-only crossgen2 tool are all redundant.
43+
RUN find /root/.nuget/packages -type f \( -name '*.nupkg' -o -name '*.snupkg' \) -delete && \
44+
find /root/.nuget/packages/gee.external.capstone -type d \( -name 'win-*' -o -name 'osx-*' -o -name 'linux-x86' -o -name 'linux-arm' \) -prune -exec rm -rf {} + && \
45+
rm -rf /root/.nuget/packages/microsoft.netcore.app.crossgen2.*
46+
3947
# Build runtime image
4048
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0.300-alpine3.23 AS runtime
4149

0 commit comments

Comments
 (0)