agentsclimarketplace

Docker development

Skill tmj-90/gaffer/runner/skills/docker-development

Use when optimising a Dockerfile, creating or improving docker-compose configurations, implementing multi-stage builds, auditing container security, or reducing image size. Triggers on "Dockerfile", "docker-compose", "container", "image size", "build cache", or "Docker best practices".From its SKILL.md

Install
npx -y skills add tmj-90/gaffer --skill docker-development

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

3.9 KB, 895 tokens by cl100k_base, as published. Nobody here has run it

Smaller images. Faster builds. Secure containers.

Opinionated Docker workflow — turn bloated Dockerfiles into production-grade containers. Three concerns: size, speed (build cache), security.

Multi-stage build pattern (every production image)

# --- build stage ---
FROM node:22-alpine AS build
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile
COPY . .
RUN pnpm build

# --- runtime stage ---
FROM node:22-alpine AS runtime
RUN addgroup -S app && adduser -S -G app app
WORKDIR /app
COPY --from=build --chown=app:app /app/dist ./dist
COPY --from=build --chown=app:app /app/node_modules ./node_modules
USER app
EXPOSE 3000
CMD ["node", "dist/main.js"]

Key principles:

  • Build tools and source code stay in the build stage; only the artifact ships.
  • Non-root user (USER app) in the runtime stage.
  • .dockerignore excludes node_modules/, .git/, *.md, test files.

Layer caching discipline

  1. Copy dependency manifests first (package.json, pnpm-lock.yaml) — before source code.
  2. Run install — cache busts only on lockfile change.
  3. Copy source — cache busts on any source change.
  4. Build — always after source copy.

Violating this order invalidates cache on every source change.

Security hardening

ControlImplementation
Non-root useraddgroup/adduser + USER directive
Read-only filesystem--read-only flag at runtime; explicit tmpfs mounts where needed
No secrets in layersBuild args for values; never ENV SECRET=...; use runtime secrets injection
Minimal base imagealpine or distroless; never latest tag
Pin digestFROM node:22-alpine@sha256:... for reproducibility
Scan at builddocker scout or trivy in CI; block on HIGH/CRITICAL CVEs

Steps

  1. Read the lore + existing Dockerfile. search_lore for existing build conventions, base image choices, and registry. Extend; don't duplicate.
  2. Audit the current state. Count layers; identify the base image and its size; check for build tools leaking into the runtime stage; look for secrets in ENV or RUN commands.
  3. Apply multi-stage build. Separate build from runtime. If only one stage is needed (static binary), still use an explicit base and non-root user.
  4. Order for cache. Dependencies before source; COPY --link where supported.
  5. Harden. Non-root user; minimal runtime image; no secrets in layers; read-only where practical.
  6. Compose (if needed). Health-check every service; use named volumes not bind mounts for data; keep .env.example in version control.
  7. Verify. Build succeeds; image scan clean; container starts and passes health check; record evidence.

Build / Test

  • docker build --no-cache to verify reproducibility.
  • trivy image <name> or docker scout cves <name> — zero HIGH/CRITICAL before shipping.
  • docker run --read-only --tmpfs /tmp to verify read-only filesystem compatibility.
  • Image size comparison: measure before and after; document the reduction.

Review checklist

  • Multi-stage build — build tools absent from runtime image.
  • Non-root userUSER directive in runtime stage.
  • Dependency manifest first — cache-friendly layer order.
  • No secrets in layersdocker history shows no credentials.
  • Base image pinned — specific version + digest; no latest.
  • Security scan clean — no HIGH/CRITICAL CVEs.

Capture lore

Base image choices, registry, and scan thresholds are high-value Dockerfile lore — call suggest_lore with tags: [docker, containers, infra].

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,834. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.