agentleFS
AnthonyPoschenAnthonyPoschen/agent-skills/skills/dockerfile/SKILL.md

dockerfile

Skill2 starsChanged 3 months agoMITView on GitHub

Create, review, or update Dockerfiles and container build workflows. Use for containerizing projects, designing multi-stage builds, choosing scratch vs Alpine final images, enforcing non-root UID/GID ownership, running build/test steps in Docker, and keeping GitHub Actions workflows thin by making the Dockerfile the local CI source of truth.

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. 0 are common, 8 are distinctive, and 10 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 8

    Distinctive

    This author's own choices. Worth a look.

  • 10

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create Dockerfiles that are secure, reproducible, and useful as the canonical local CI build.

    line 15
  2. Very specific:

    If the output is a single static binary, aim for a scratch final image.

    line 22
  3. Very specific:

    If the output needs an interpreter, shared libraries, package files, or runtime dependencies, aim for an Alpine final image such as …

    line 23
  4. Distinctive:

    If Alpine is incompatible with required native dependencies, explain why and choose the smallest appropriate runtime base.

    line 26
  5. Distinctive:

    Keep build tools, test tools, package managers, and source code out of the final image unless they are required at runtime.

    line 28
  6. Very specific:

    Add ARG UID=10001 and ARG GID=10001 in every stage that creates or owns files used by the runtime image.

    line 33
  7. Very specific:

    Run the final container as non-root with USER ${UID}:${GID} or a named user created from those args.

    line 35
  8. Very specific:

    Ensure every file used by the final executable is owned by the runtime UID/GID.

    line 37
  9. Very specific:

    Prefer COPY --chown=${UID}:${GID} for final-stage copies.

    line 38
  10. Very specific:

    Use exec-form ENTRYPOINT or CMD.

    line 45
  11. Distinctive:

    Use a dedicated build stage for compilation, dependency installation, and generated artifacts.

    line 49
  12. Very specific:

    Add a test stage when the project has a clear test command.

    line 51
  13. Very specific:

    Keep the Dockerfile sufficient for local CI verification so GitHub Actions can usually be a simple docker build plus optional image push.

    line 58
  14. Distinctive:

    Use BuildKit cache mounts when they improve repeat builds and the project already assumes BuildKit.

    line 60
  15. Very specific:

    Write a .dockerignore if missing or incomplete.

    line 69
  16. Distinctive:

    Ensure final-stage ownership, non-root user, and minimal copied files.

    line 71
  17. Distinctive:

    If asked for CI, make the workflow invoke the Dockerfile rather than duplicating build logic.

    line 72
  18. Distinctive:

    Read references/patterns.md when writing concrete Dockerfile examples or adapting this policy to Go, Rust, Python, Node, or a plain Alpine …

    line 79

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “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

Dockerfile

Goal

Create Dockerfiles that are secure, reproducible, and useful as the canonical local CI build. Prefer multi-stage builds unless the user explicitly asks for a single-stage file.

Decision Order

  1. Identify the final runtime artifact.
  2. If the output is a single static binary, aim for a scratch final image.
  3. If the output needs an interpreter, shared libraries, package files, or runtime dependencies, aim for an Alpine final image such as python:<version>-alpine, node:<version>-alpine, or plain alpine.
  4. If Alpine is incompatible with required native dependencies, explain why and choose the smallest appropriate runtime base.
  5. Keep build tools, test tools, package managers, and source code out of the final image unless they are required at runtime.

Required Container Policy

  • Add ARG UID=10001 and ARG GID=10001 in every stage that creates or owns files used by the runtime image.
  • Run the final container as non-root with USER ${UID}:${GID} or a named user created from those args.
  • Ensure every file used by the final executable is owned by the runtime UID/GID. Prefer COPY --chown=${UID}:${GID} for final-stage copies.
  • For scratch, use numeric USER ${UID}:${GID} and copy only required files: the static binary, CA certificates when outbound TLS is needed, and any minimal config/data files the binary actually reads.
  • For Alpine runtime images, create the user/group from UID and GID, then copy application files with that owner.
  • Set a narrow WORKDIR; do not run from filesystem root.
  • Use exec-form ENTRYPOINT or CMD.

Build And Test Pattern

  • Use a dedicated build stage for compilation, dependency installation, and generated artifacts.
  • Add a test stage when the project has a clear test command. Examples: go test ./..., cargo test --locked, npm test, pytest. Skip tests that need cluster or network from a container build. Keep cluster tools such as kubectl out of the final image.
  • Make the default Docker build exercise tests when practical by having the production stage depend on the tested artifact path, or document: docker build --target test ..
  • Keep the Dockerfile sufficient for local CI verification so GitHub Actions can usually be a simple docker build plus optional image push.
  • Use BuildKit cache mounts when they improve repeat builds and the project already assumes BuildKit.

Workflow

  1. Inspect the project manifest and lock files before writing the Dockerfile.
  2. Determine whether the runtime is a static binary, dynamic binary, or dynamic language/runtime app.
  3. Choose the final image using the decision order above.
  4. Write a .dockerignore if missing or incomplete.
  5. Include test and build stages that match the project tooling.
  6. Ensure final-stage ownership, non-root user, and minimal copied files.
  7. If asked for CI, make the workflow invoke the Dockerfile rather than duplicating build logic.
  8. Validate with docker build when Docker is available; otherwise report that validation was not run.

Pattern Reference

Read references/patterns.md when writing concrete Dockerfile examples or adapting this policy to Go, Rust, Python, Node, or a plain Alpine runtime.

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.