dockerfile-cache-xp

Converts CI Dockerfiles into cache-optimized Dockerfile.local variants with nerdctl build commands.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/peachest/skills --skill dockerfile-cache-xp-peachest
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dockerfile-cache-xp
Source: https://github.com/peachest/skills/tree/main/in-progress/dockerfile-cache-xp
Command: npx skills add https://github.com/peachest/skills --skill dockerfile-cache-xp-peachest

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? CI Dockerfiles are built for reproducibility from a clean state, so every local build pays the full cost of downloading dependencies and recompiling from scratch. This Skill rewrites them to maximize BuildKit layer-cache reuse, turning source-only edits into minutes-long rebuilds instead of full rebuilds. ## Core Features & Use Cases - Cache-mount rewriting: Adds --mount=type=cache with explicit project-prefixed id= values to every RUN that downloads or compiles, with sharing=locked on compile-output mounts. - Language-specific rules: Applies Go layered COPY (go.mod/go.sum → go mod download → source) or Rust full-COPY with partitioned cargo cache mounts, based on the detected build language. - Ready-to-run build command: Assembles the nerdctl command with four-case proxy build args, NO_PROXY, and harbor registry tagging, resolving the proxy from the environment rather than hardcoding it. - Use Case: You have a Go service whose CI Dockerfile takes 25 minutes to rebuild locally after every code edit. Run this Skill to produce a Dockerfile.local that caches the module graph and build cache, so subsequent builds only recompile changed source. ## Quick Start Convert my CI Dockerfile at docker/Dockerfile into a cache-optimized Dockerfile.local and give me the nerdctl build command to run it.

Frequently Asked Questions about dockerfile-cache-xp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I speed up local Docker builds with BuildKit cache mounts?▼

Add --mount=type=cache to every RUN that downloads or compiles, with an explicit id= prefixed by the project name. Mount the tool's cache directory (cargo registry, GOMODCACHE) so dependency downloads and incremental artifacts survive across builds.

How to cache Go module downloads in a Dockerfile?▼

Copy go.mod and go.sum first, run go mod download with a cache mount on GOMODCACHE, then copy source in a separate layer. The dependency layer only invalidates when manifests change, isolating it from source edits.

Why does layered COPY of Cargo.toml fail for Rust workspaces?▼

cargo fetch --locked resolves every workspace member's manifest and checks target files like src/lib.rs referenced in [lib] sections, so copying manifests without source fails. The working approach is full source COPY plus cache mounts on the cargo registry, git, and target directories.

Does nerdctl support proxy flags for builds?▼

nerdctl has no --proxy-http or --proxy-https flags, and buildkitd does not inherit shell proxy environment variables. Pass proxies via --build-arg in both upper and lower case, plus NO_PROXY for internal registries.

When should I use sharing=locked on BuildKit cache mounts?▼

Use sharing=locked on compile-output mounts like target/ or go-build. Concurrent builds writing the same output directory corrupt incremental artifacts, and locked serializes access to prevent that.

Can I push multi-arch images with nerdctl?▼

Build with --platform amd64,arm64 to create a single manifest list, then push with --all-platforms. Without --all-platforms, nerdctl pushes only the current platform's image.