Skip to content
Back to skills

Docker Build Optimized

ASecurity

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.

  • 5 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 23, 2026
developmentpythonnodedockergit

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add alvaroofernaandez/aval --skill docker-build-optimized --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Docker Build Optimized?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Docker Build Optimized
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alvaroofernaandez-docker-build-optimized-aval/badge)](https://www.skillsdirectory.com/skills/alvaroofernaandez-docker-build-optimized-aval)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: docker-build-optimized
description: "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."
metadata:
  author: "alvaroofernaandez"
  version: "2.0"
---

## 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`. 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

| Finding | Recommendation |
|---|---|
| Build toolchain ends up in final image | Multi-stage: `build` stage → minimal runtime stage |
| No `.dockerignore` or it misses `.git`, `node_modules`, `.venv`, `dist`, `.env*` | Add/extend it |
| `COPY . .` before dependency install | Copy lockfiles first, install, then copy source |
| Dependencies re-download every build | `RUN --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 separately | Merge install + cleanup in one layer |
| amd64-only target | `--platform linux/amd64` on the `multiarch` builder, then verify the architecture |
| `InvalidBaseImagePlatform` warning | Wrong 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 `aval docker cleanup`.

## Output Contract

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

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.