github avatar

Multi Stage Dockerfile

The multi-stage-dockerfile skill helps developers create optimized Docker container images by guiding them through best practices for multi-stage builds, base image selection, layer optimization, and security hardening. It addresses the problem of bloated, insecure, or inefficient container images by providing specific techniques for separating build and runtime stages, minimizing final image size, and reducing security vulnerabilities. This skill is for software developers and DevOps engineers working with containerized applications across any language or framework who want to improve build efficiency and image quality.

skills.sh installs
31.5K
GitHub stars
41K
last updated
Aug 21, 2026

Install

$ npx -y skills add github/awesome-copilot --skill multi-stage-dockerfile --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/github/awesome-copilot
Categories
Git & Pull Requests, AI & Agent Building

More from github/awesome-copilot

All 318
1github avatardocumentation-writergithub/awesome-copilotDiátaxis Documentation Expert. An expert technical writer specializing in creating high-quality software documentation, guided by the principles and structure o28.4Kskills.sh installs
2github avatarprdgithub/awesome-copilotGenerate high-quality Product Requirements Documents (PRDs) for software systems and AI-powered features. Includes executive summaries, user stories, technical 24.4Kskills.sh installs
3github avatarrefactorgithub/awesome-copilotSurgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, im22.6Kskills.sh installs
4github avatarjava-springbootgithub/awesome-copilotGet best practices for developing applications with Spring Boot.21.8Kskills.sh installs
5github avatargh-cligithub/awesome-copilotGitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, projects, releases, gists, codespaces, organizations, extensions, and 21.2Kskills.sh installs
6github avatarcreate-readmegithub/awesome-copilotCreate a README.md file for the project19.5Kskills.sh installs