multi-stage-dockerfile

Creates optimized multi-stage Dockerfiles for any language or framework.

Updated Aug 28, 2026
One-click install
npx skills add https://github.com/miyake-san/sogo-agent-platform --skill multi-stage-dockerfile-miyake-san
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: multi-stage-dockerfile
Source: https://github.com/miyake-san/sogo-agent-platform/tree/main/skills/experimental/multi-stage-dockerfile
Command: npx skills add https://github.com/miyake-san/sogo-agent-platform --skill multi-stage-dockerfile-miyake-san

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Dockerfiles that produce large, insecure images is a common problem. This Skill guides the creation of multi-stage Dockerfiles that separate build-time and runtime concerns, resulting in smaller and more secure container images. ## Core Features & Use Cases - Multi-Stage Structure: Separates builder and runtime stages, copying only necessary artifacts between stages with meaningful stage names. - Layer & Image Optimization: Orders layers for maximum build cache reuse, uses minimal base images like slim, Alpine, or distroless variants, and applies .dockerignore rules. - Security Hardening: Enforces non-root users, removes build tools from final images, and keeps build secrets out of runtime layers. - Use Case: You have a Node.js application whose image is over 1GB because it ships dev dependencies and build tools. Use this Skill to restructure the Dockerfile into builder and runtime stages, cutting the final image to a fraction of its size. ## Quick Start Create an optimized multi-stage Dockerfile for my Python application using a slim base image and a non-root user.

Frequently Asked Questions about multi-stage-dockerfile

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a multi-stage Dockerfile?

Define a builder stage with FROM ... AS builder for compilation and dependency installation, then a separate runtime stage that copies only the built artifacts using COPY --from=builder. Order stages as dependencies, build, test, then runtime.

How do I reduce Docker image size?

Use multi-stage builds so the final image contains only runtime artifacts, choose minimal base images like slim, Alpine, or distroless variants, combine related RUN commands with &&, and add a .dockerignore file to exclude unnecessary files from the build context.

What base image should I use for Docker runtime stages?

Use official minimal images with exact version tags such as python:3.11-slim for reproducibility. Consider distroless images for runtime stages or Alpine-based images when compatible with your application for a smaller footprint.

How do I make Docker builds use layer caching effectively?

Order instructions from least to most frequently changing: install dependencies before copying application code. This lets Docker reuse cached layers for dependency installation when only source code changes between builds.

How do I run a Docker container as a non-root user?

Add a USER instruction in the runtime stage specifying a non-root user, and use COPY --chown to set file ownership in one step. Also remove build tools and unnecessary packages from the final image to reduce the attack surface.