Skip to main content
skill GitHub Copilot official · GitHub

multi-stage-dockerfile — GitHub Copilot skill: setup

This skill guides GitHub Copilot in writing multi-stage Dockerfiles for different languages and frameworks. Use it when the final runtime image should contain fewer build dependencies.

Install into GitHub Copilot · Skills CLI (Vercel) All methods and platforms ↓
npx skills add github/awesome-copilot --skill multi-stage-dockerfile
Open on GitHub

What multi-stage-dockerfile does

The skill guides an agent through separating application builds from runtime execution. A builder stage handles dependency installation and compilation, while a runtime stage receives only the artifacts required to run the app. The suggested flow is dependencies, build, tests, then runtime.

Its guidance covers minimal official images, exact version tags, layer-cache ordering, and .dockerignore. It also calls for removing build tools from the final image, using a non-root USER, setting restrictive permissions, and adding an appropriate HEALTHCHECK.

Install it when Copilot should prepare Dockerfiles across different stacks. For a small app with no separate build step, this skill may add more structure than you need.

What it helps with

  • split compilation and runtime into separate stages
  • copy only required artifacts into the final image
  • order Docker layers for better cache reuse
  • remove build packages from the runtime image
  • run the container as a non-root user

Example prompts for the agent

  • Create a multi-stage Dockerfile for this app with separate dependency, build, test, and runtime stages.
  • Review this Dockerfile and improve layer caching, add `.dockerignore`, and remove unnecessary runtime packages.
  • Prepare a runtime stage that uses a non-root user and an appropriate `HEALTHCHECK`.

How to install multi-stage-dockerfile

1Skills CLI (Vercel)

npx skills add github/awesome-copilot --skill multi-stage-dockerfile

2GitHub CLI

gh skill install github/awesome-copilot multi-stage-dockerfile

3Manually: put the files in place

.github/skills/multi-stage-dockerfile/SKILL.md

From the same set554

The whole set →
git-commit official github This skill reviews Git changes, stages related files, and creates Conventional Commits. Use it when you want an agent to make one commit or split work into separate commits. GitHub Copilot 47,165installs excalidraw-diagram-generator official github Turn a plain-language description into an Excalidraw diagram. Useful for mapping processes, system structure, and relationships between entities. GitHub Copilot 31,639installs documentation-writer official github Skill that turns the agent into a technical writer following the Diátaxis framework: tutorials, how-to guides, reference, and explanation. Proposes structure before writing. GitHub Copilot 27,757installs prd official github Turns a feature idea into a structured PRD with user stories, technical requirements, and risks. Use it when planning a software feature or an AI-powered one. GitHub Copilot 24,035installs refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. GitHub Copilot 22,321installs java-springboot official github Gives GitHub Copilot Spring Boot development practices, from project layout to tests and security. Use it when writing or reviewing Java application code. GitHub Copilot 21,272installs create-readme official github This skill reviews a project and creates a structured README.md. Use it when the repository needs clear documentation based on its actual files and code. GitHub Copilot 19,081installs playwright-generate-test official github Generates a Playwright test from a scenario through Playwright MCP. Use it when the browser flow should be completed before test code is written. GitHub Copilot 18,162installs

Similar

sonoscli openclaw Wires the sonos binary into your agent so it can find speakers on the LAN, set volume, group rooms and start playback. Claude Code CX Codex Cursor +1 5,300installs camsnap openclaw A skill for snapshots, clips, motion watches, and USB PTZ control across RTSP/ONVIF cameras and local webcams. Use it when an agent needs camera access. Claude Code CX Codex Cursor +1 5,100installs gh-issues openclaw This skill finds GitHub issues, starts background fix agents, and opens PRs. Use it when you want an issue-to-PR workflow with optional review handling. Claude Code CX Codex Cursor +1 5,000installs fix react The skill formats changed files and checks for remaining lint issues before a commit. Use it when code needs to pass CI checks. Claude Code CX Codex Cursor +1 2,300installs release-skills JimLiu Automates release workflows, conventional commit parsing, and version bumps for Node.js, Python, or Rust. Builds changelogs and creates GitHub Releases. Claude Code CX Codex Cursor +1 25,600installs playwright-dev microsoft Explains how to develop Playwright: add APIs, MCP tools, CLI commands, and manage vendor dependencies. Claude Code CX Codex Cursor +1 3,700installs wizard Matt Pocock This skill creates an interactive bash wizard for manual setup steps, CI secrets, third-party dashboards, and one-off migrations. Claude Code 553,369installs hyperframes-cli heygen-com Controls HyperFrames video workflows from the CLI: audits layouts and contrast, edits timeline clips, captures snapshots, and renders locally or in cloud runtimes. Claude Code CX Codex Cursor +1 1,200,000installs

Questions about multi-stage-dockerfile

How do I install multi-stage-dockerfile in GitHub Copilot?

Run npx skills add github/awesome-copilot --skill multi-stage-dockerfile. The skill file is then available at .github/skills/multi-stage-dockerfile/SKILL.md.

What does multi-stage-dockerfile do?

It guides the agent in separating build steps from runtime steps and copying only required artifacts into the final Docker image. The guidance also covers layer caching and basic container security.

Which languages does multi-stage-dockerfile support?

The skill is intended for applications written in different languages and frameworks. Base-image choices still depend on application compatibility, especially with Alpine or distroless images.

Source text

SKILL.md · MIT
---
name: multi-stage-dockerfile
description: 'Create optimized multi-stage Dockerfiles for any language or framework'
---

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

© github · MIT · github/awesome-copilot

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor