perf: keep build caches out of the image (uv/go/cargo/apt) - #16
Open
ai-anant wants to merge 1 commit into
Open
Conversation
The image accumulated build-time caches that serve no runtime purpose: - uv download cache (semgrep/ast-grep wheels) in /root/.cache/uv - go build+module cache after compiling gosec (~/.cache, ~/go) - cargo registry+git+target after compiling cargo-audit (~1GB) - apt archives and stale gem cache Move uv downloads to BuildKit cache mounts (--mount=type=cache) so they live in the builder cache, not the image; point GOCACHE/GOPATH and CARGO_TARGET_DIR at /tmp and remove them after install; apt-get clean + drop apt archives and gem cache. Refs cyfinoid#10
This was referenced Aug 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The aidc image was shipping build-time caches that serve no runtime purpose, inflating every project image by roughly 0.5–1.5 GB depending on toolchains:
/root/.cache/uv) — semgrep + ast-grep wheels (~100s MB)gosec(~/.cache/go-build,~/go)cargo-audit --lockedfrom source (~1 GB)bundler-auditChanges (
templates/devcontainer/Dockerfile.tmpl)RUN --mount=type=cache,target=/root/.cache/uv) — downloaded wheels live in the builder cache (fast rebuilds) but never land in the image.GOPATH=/tmp/gopath GOCACHE=/tmp/go-buildfor thegoseccompile, thenrm -rf— keeps the module cache out of~/.cache/~/go.CARGO_TARGET_DIR=/tmp/cargo-targetfor thecargo-auditcompile, then removes/tmp/cargo-target,~/.cargo/registry,~/.cargo/git. The installedcargo-auditbinary (symlinked into~/.local/bin) survives.apt-get clean+ remove/var/cache/apt/archives/*.debin the base layer; the toolchain loop already cleans apt lists.bundler-audit.checkov,bandit):uv cache cleanafter install (no cache mount there since they run asvscode).Requires BuildKit (Docker 23+ default; compose v2 uses it automatically).
docker build --checkpasses.Expected impact
semgrep,gosec,cargo-audit,bandit,checkov) remain on PATH.Test plan
docker build --checkon the template (BuildKit parse, no warnings)bash -n,shellcheck -x, bash-3.2 compat check — cleantests/resolve-oauth-token.test.sh— 7/7 passCloses #10