Index of every page on this site: llms.txt
All skills
github avatar

/multi-stage-dockerfile

@f10fdb8 official
by githubgithub/awesome-copilot42k stars
5,426
Run it yourself

Create optimized multi-stage Dockerfiles for any language or framework

Use this Skill: https://skilld.dev/gh/github/awesome-copilot/multi-stage-dockerfile

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈24 tokens for metadata: the name and description. ≈548 when used: this file.

Description uses 1.2% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈95 characters, or 1.2%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Your goal is to help me create efficient multi-stage Dockerfiles that follow best practices, resulting in smaller, more secure container images.

Multi-Stage Structure

  • Use a builder stage for compilation, dependency installation, and other build-time operations
  • Use a separate runtime stage that only includes what's needed to run the application
  • Copy only the necessary artifacts from the builder stage to the runtime stage
  • Use meaningful stage names with the AS keyword (e.g., FROM node:18 AS builder)
  • Place stages in logical order: dependencies → build → test → runtime

Base Images

  • Start with official, minimal base images when possible
  • Specify exact version tags to ensure reproducible builds (e.g., python:3.11-slim not just python)
  • Consider distroless images for runtime stages where appropriate
  • Use Alpine-based images for smaller footprints when compatible with your application
  • Ensure the runtime image has the minimal necessary dependencies

Layer Optimization

  • Organize commands to maximize layer caching
  • Place commands that change frequently (like code changes) after commands that change less frequently (like dependency installation)
  • Use .dockerignore to prevent unnecessary files from being included in the build context
  • Combine related RUN commands with && to reduce layer count
  • Consider using COPY --chown to set permissions in one step

Security Practices

  • Avoid running containers as root - use USER instruction to specify a non-root user
  • Remove build tools and unnecessary packages from the final image
  • Scan the final image for vulnerabilities
  • Set restrictive file permissions
  • Use multi-stage builds to avoid including build secrets in the final image

Performance Considerations

  • Use build arguments for configuration that might change between environments
  • Leverage build cache efficiently by ordering layers from least to most frequently changing
  • Consider parallelization in build steps when possible
  • Set appropriate environment variables like NODE_ENV=production to optimize runtime behavior
  • Use appropriate healthchecks for the application type with the HEALTHCHECK instruction

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning2mo5 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill contains documentation regarding Docker best practices and does not include any executable code or external dependencies.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • Runlayer9mo

    1/1 file flagged

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at f10fdb8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated 7 months ago
  • Security
  • docker
  • dockerfile
  • multi-stage
  • container
  • build-optimization
  • image-size
  • caching

README badge

README badge for github/awesome-copilot/multi-stage-dockerfile

Generates multi-stage Dockerfiles with builder and runtime stages optimized for minimal image size and security across any language or framework. Covers layer caching, base image selection, non-root users, and build artifact separation to follow Docker best practices.

Generated from the current SKILL.md.

Does this skill work with all programming languages?
Yes. The skill provides language-agnostic multi-stage Dockerfile patterns. Examples and best practices apply to Node.js, Python, Go, Java, and other compiled or interpreted languages.
Does this skill help reduce final image size?
Yes. By using separate builder and runtime stages, copying only necessary artifacts, and selecting minimal base images (Alpine, distroless), the final image excludes build tools and dependencies needed only during compilation.
Does this skill address security concerns in Docker images?
Yes. The skill covers running containers as non-root users, removing build tools from final images, using multi-stage builds to exclude secrets, and scanning for vulnerabilities.
Can I use this skill if my application doesn't require compilation?
Yes. The skill applies to interpreted languages too. You can still benefit from multi-stage separation—for example, keeping development dependencies out of the runtime stage.

Generated from the current SKILL.md. These answers refresh after source changes.