Skip to content

Conversation

@mbouaziz
Copy link
Contributor

Summary

  • Replace explicit cache cleanup (apt-get clean, npm cache clean, pip cache purge, rm -rf ~/.gradle) with BuildKit --mount=type=cache
  • Cache volumes persist between builds for faster rebuilds but are never included in image layers
  • Add --no-install-recommends to all apt-get install calls
  • Add ca-certificates explicitly for HTTPS apt repos (needed with --no-install-recommends)
  • Add npm explicitly alongside nodejs (recommended dep, skipped with --no-install-recommends)

Files changed

  • skiplang/Dockerfile — apt cache mounts
  • sql/Dockerfile — apt, npm, SDKMAN cache mounts
  • Dockerfile — apt, npm, pip cache mounts
  • sql/server/core/Dockerfile — Gradle cache mount
  • sql/server/dev/Dockerfile — Gradle cache mount
  • skipruntime-ts/tests/native_addon/Dockerfile — apt, npm cache mounts
  • skipruntime-ts/tests/native_addon_unreleased/Dockerfile — apt, npm cache mounts

Measured impact (skiplang/Dockerfile base stage)

Method Size
No cleanup (registry) 2.03 GB
Explicit apt-get clean 1.14 GB
BuildKit cache mounts 636 MB

Notes

  • --mount=type=cache requires BuildKit (default since Docker 23.0, Jan 2023)
  • release_docker.sh already uses docker buildx build (full BuildKit)
  • --no-cache flag in build scripts disables layer caching but does NOT affect cache mount volumes
  • sharing=locked prevents cache corruption during parallel builds

Test plan

  • docker build --no-cache -f skiplang/Dockerfile --target base . — builds successfully
  • clang --version — LLVM 20.1.8 works
  • Image contains no apt cache (0 files in /var/lib/apt/lists/)
  • CI passes

🤖 Generated with Claude Code

mbouaziz and others added 6 commits February 12, 2026 17:09
Replace explicit apt cache cleanup with --mount=type=cache.
Cache volumes persist between builds for faster rebuilds
but are never included in image layers.

Also add ca-certificates explicitly since --no-install-recommends
skips it, and it's needed for HTTPS access to apt.llvm.org.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace explicit cache cleanup with --mount=type=cache for apt,
npm, and SDKMAN archives.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace explicit cache cleanup with --mount=type=cache for apt,
npm, and pip caches.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace explicit Gradle cache cleanup with --mount=type=cache.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace explicit cache cleanup with --mount=type=cache for apt
and npm caches.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Nodesource's nodejs package bundles npm. Installing Ubuntu's
separate npm package alongside it causes conflicts. Remove
the explicit npm from apt-get install.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mbouaziz mbouaziz changed the title Use BuildKit cache mounts for package manager caches AIGEN Use BuildKit cache mounts for package manager caches Feb 13, 2026
mbouaziz and others added 2 commits February 13, 2026 10:37
With --no-install-recommends, ca-certificates is not pulled in
automatically. Without it, wget can't fetch the nodesource setup
script over HTTPS, causing apt to fall back to Ubuntu's nodejs 18
which doesn't include npm.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use TARGETARCH in cache mount IDs to prevent cross-architecture
contamination when building for multiple platforms sequentially.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant