sandbox: shrink image by ~2GB (go modcache, locales, docs)#474
sandbox: shrink image by ~2GB (go modcache, locales, docs)#474seanturner83 wants to merge 2 commits into
Conversation
Three safe reclamations to containers/Dockerfile that trim the final image from ~9.8GB to ~7.5GB without removing any user-facing tool: - `go clean -modcache` after the ProjectDiscovery installs removes ~1.7GB of Go module sources. The resulting binaries in /home/pentester/go/bin are self-contained and don't need the module cache at runtime. - Purge non-English glibc locales (~160MB). Sandbox runs with LANG=C.UTF-8 implicitly; no locale beyond en/en_US/C is used. - Remove /usr/share/doc, /usr/share/doc-base, and /usr/share/man (~95MB). Runtime doesn't call man or read package docs. Verified by building + smoke-testing the slim image: all path-visible tools (semgrep, nuclei, httpx, katana, trivy, zaproxy, trufflehog, gitleaks, sqlmap, ffuf, subfinder, naabu, bandit, arjun, dirsearch, wafw00f, tree-sitter, ast-grep, eslint, retire, jshint, js-beautify, wapiti) report version / usage cleanly on the slim image.
Greptile SummaryThis PR reduces the sandbox image by ~2.3 GB through three targeted cleanups in Confidence Score: 4/5Safe to merge; all three reclamations are correct and non-breaking, with only a minor style note. No P0 or P1 issues found. The single P2 observation (vestigial man-db install) does not affect correctness or runtime behavior. The go modcache clean is correctly co-located in the same layer, locale purge is conservative and preserves English, and doc removal happens after all apt installs. No files require special attention. Important Files Changed
|
man-db is vestigial once the man page tree is removed in the cleanup layer — the man binary has nothing to serve. Dropping it from the install list recovers a few more MB and avoids shipping a no-op package + its dependencies (groff-base, libpipeline1, etc). Raised by greptile on the slim-image PR.
Summary
Three safe reclamations to
containers/Dockerfilethat shrink the final image by ~2.3GB / ~23% without removing any user-facing tool:go clean -modcacheaftergo installchainen,en_US,C)/usr/share/{doc,doc-base,man}Measured: 9.78GB → 7.49GB on linux/amd64 build.
Why
The sandbox image is pulled per-scan in CI setups that use Strix, and cold-runner
docker pull/docker loadtimes are ~3-5 min, dominating the warm-up envelope for fast scans. Trimming ~2GB directly reduces that latency. No functional change — every binary present before is present after.Safety
Go modcache.
go install -v <pkg>@latestdownloads sources into$GOPATH/pkg/modand produces a statically-linked binary in$GOPATH/bin. The binaries don't reference the module cache at runtime.go clean -modcacheremoves the source tree; subsequentgo installinvocations re-download on demand (same behaviour as a fresh container).Verified locally by running each Go binary after the clean:
Locales. The image runs with
LANG=C.UTF-8implicitly (no explicitLANG=set, nolocalespackage pulled in with a locale-gen step). glibc falls back toCwhen requested locales are absent. Purging/usr/share/locale/*excepten,en_US,Cchanges nothing for any process running in the sandbox.Docs/man. Tool runtime doesn't call
manor read/usr/share/doc/*. Package postinst scripts reference these during install, not at runtime.All three reclamations ride inside the existing
apt-get autoremovecleanup layer, so no new layer is introduced.Smoke test (manual, linux/amd64)
All tools report OK on the slim image. Size confirmed via
docker images.Non-goals
docker-entrypoint.sh, Caido proxy, or Python/Node runtime.github/workflows/*that builds the sandbox today, so this PR has been tested manually)