agentleFS
alvaroofernaandezalvaroofernaandez/aval/skills/docker-build-optimized/SKILL.md

docker-build-optimized

Skill5 starsChanged 2 days agoMITView on GitHub

Trigger: Dockerfile, docker build, imagen pesada, build lento, multi-stage, .dockerignore, buildx cache. Build small, fast, well-cached images on Kiri with the multiarch builder.

  • Reads credentials

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read Dockerfile, .dockerignore and the compose file BEFORE building or editing.

    line 15
  2. Very specific:

    If build cache exceeds ~10 GB or / has < 20 GiB free, suggest docker-space-optimizer.

    line 41

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Activation Contract

Load when writing or reviewing a Dockerfile, .dockerignore, compose.yaml/docker-compose.yml, or when a build is slow, an image is large, or caching misbehaves.

Hard Rules

  • Read Dockerfile, .dockerignore and the compose file BEFORE building or editing.
  • Build against the kiri context with BUILDX_BUILDER=multiarch (see kiri-docker). Never build deploy images on Kiri's own kiri builder: it can silently return ARM64 for --platform linux/amd64.
  • Pin base images to a version tag (e.g. node:22.11-alpine, python:3.12-slim); never latest.
  • Show proposed Dockerfile changes as a diff and explain each; do not rewrite build files the user did not ask to change.
  • Tag images consistently: <app>:<git-short-sha> or <app>:local for dev; never rely on implicit latest.

Decision Gates

FindingRecommendation
Build toolchain ends up in final imageMulti-stage: build stage → minimal runtime stage
No .dockerignore or it misses .git, node_modules, .venv, dist, .env*Add/extend it
COPY . . before dependency installCopy lockfiles first, install, then copy source
Dependencies re-download every buildRUN --mount=type=cache,target=<pkg cache>
Full distro base for a static/interpreted app-slim, -alpine or distroless — only if native deps allow
Many RUN lines cleaning caches separatelyMerge install + cleanup in one layer
amd64-only target--platform linux/amd64 on the multiarch builder, then verify the architecture
InvalidBaseImagePlatform warningWrong builder: echo $BUILDX_BUILDER must be multiarch

Execution Steps

  1. Inspect the build files and the current image size (docker image ls <app>).
  2. Apply the approved recommendations from the table.
  3. Build: docker buildx build --tag <app>:local --load . or docker compose up -d --build (builder multiarch, default-load=true).
  4. For any image to push or deploy, verify: docker image inspect -f '{{.Architecture}}' <image> must print amd64 (or the intended arch). Do not push otherwise.
  5. Report: docker image ls, docker system df.
  6. If build cache exceeds ~10 GB or / has < 20 GiB free, suggest docker-space-optimizer.

Output Contract

Return: changes applied (diff), build command, image size before/after, build time if measured, and docker system df summary.

References

  • ../kiri-docker/SKILL.md — runtime rules.
  • ../docker-space-optimizer/SKILL.md — cache cleanup.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.