multi-stage-dockerfile — скилл для Copilot: что делает и установка
Скилл помогает создавать многоэтапные Dockerfile для разных языков и фреймворков. Пригодится, когда важны размер и состав runtime-образа.
npx skills add github/awesome-copilot --skill multi-stage-dockerfile -a claude-codeЧто делает multi-stage-dockerfile
Скилл помогает агенту разделить сборку и запуск приложения по разным стадиям Dockerfile. В builder stage помещаются установка зависимостей и компиляция, а runtime stage получает только нужные артефакты. Рекомендуемый порядок такой: зависимости, сборка, тесты, запуск.
В правилах есть работа с официальными минимальными образами, точными тегами версий, кэшем слоёв и .dockerignore. Скилл также подсказывает, как убрать инструменты сборки из финального образа, запускать контейнер не от root, задать права и добавить HEALTHCHECK.
Ставьте его, если агент должен регулярно готовить Dockerfile под разные стеки. Для простого контейнера без отдельной сборки эти рекомендации могут оказаться избыточными.
Какие задачи решает
- разделить сборку и запуск приложения по стадиям
- собрать runtime-образ только с нужными артефактами
- настроить кэширование зависимостей и слоёв Docker
- убрать инструменты сборки из финального образа
- запускать контейнер от непривилегированного пользователя
Примеры запросов агенту
- Создай multi-stage Dockerfile для этого приложения и раздели зависимости, сборку и runtime.
- Проверь Dockerfile: улучши кэширование слоёв, добавь `.dockerignore` и убери лишние пакеты из финального образа.
- Подготовь финальную стадию с запуском не от root и подходящим `HEALTHCHECK`.
Как установить multi-stage-dockerfile
1Через Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill multi-stage-dockerfile -a claude-code2Вручную: положить файлы
~/.claude/skills/multi-stage-dockerfile/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/multi-stage-dockerfile/
Вручную: положить файлы
.agents/skills/multi-stage-dockerfile/SKILL.mdДля всех проектов — ~/.agents/skills/
Вручную: положить файлы
.cursor/skills/multi-stage-dockerfile/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1Через Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill multi-stage-dockerfile2GitHub CLI
gh skill install github/awesome-copilot multi-stage-dockerfile3Вручную: положить файлы
.github/skills/multi-stage-dockerfile/SKILL.mdКомандой платформы
gemini skills install https://github.com/github/awesome-copilot --path skills/multi-stage-dockerfileВручную: положить файлы
.devin/skills/multi-stage-dockerfile/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Claude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
Похожие
Вопросы о multi-stage-dockerfile
Как установить multi-stage-dockerfile в GitHub Copilot?
Выполните npx skills add github/awesome-copilot --skill multi-stage-dockerfile, затем скилл будет доступен по пути .github/skills/multi-stage-dockerfile/SKILL.md.
Что делает multi-stage-dockerfile?
Он помогает создавать многоэтапные Dockerfile: отделяет сборку от запуска и переносит в финальный образ только нужные артефакты. Также он учитывает кэш слоёв и базовые меры безопасности.
Для каких языков подходит multi-stage-dockerfile?
Скилл рассчитан на приложения на разных языках и фреймворках. Базовый образ нужно выбирать с учётом совместимости приложения, особенно при использовании Alpine или distroless.
Исходный текст
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