multi-stage-dockerfile
できること
このAIエージェントは、コンテナでプログラムを実行するための効率的なDockerfileの作成を支援します。工程を複数のステージに分けることで、最終的な成果物がより小さく、安全で、高速になるようにします。
使う場面
- ✓プログラムをどこでも実行できる「パッケージ」を作成したいとき。
- ✓プログラムの「パッケージ」をできるだけ小さくしたいとき。
- ✓プログラムの「パッケージ」を攻撃からより安全に守りたいとき。
スキルのリンク
https://github.com/github/awesome-copilot/blob/main/skills/multi-stage-dockerfile/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“Reactを使用したNode.jsアプリケーション用に、最適化されたDockerfileを作成してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
「マルチステージビルド」という手法を使います。ひとつのステージでプログラムをビルドし、別のよりクリーンなステージでそれを実行するだけにします。これにより、必要なものだけが最終的な成果物に含まれるようになります。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
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
ASkeyword (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-slimnot justpython) - 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
.dockerignoreto 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
USERinstruction 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
よくある質問
Dockerfileとは何ですか?
Dockerに対して、プログラムを実行するための隔離された環境(コンテナ)を作成する指示を書いたテキストファイルです。
「マルチステージ」の方がよいのはなぜですか?
プログラムをビルドするためのツールと、実行環境を分離するためです。その結果、最終的なコンテナがずっと小さく、より安全になります。
「コンテナ」とは何ですか?
プログラムの実行に必要なものをすべて収めた、隔離された箱のようなものです。これにより、さまざまなコンピュータで簡単に実行できます。
詳細
作者による元の説明
Create optimized multi-stage Dockerfiles for any language or framework
repo: github/awesome-copilot
人気
- GitHubのスター
- 40k
- ランキング
- #7301
- ライセンス
- MIT
- 更新日
- 2026/10/15
コメント
- …
このリポジトリの他のスキル
acquire-codebase-knowledge
40kエージェントが、既存のコードプロジェクトを理解してドキュメント化できるよう支援します。新しく参加するメンバーのオンボーディングや、アーキテクチャの全体像の把握に役立ちます。
acreadiness-assess
40kエージェントが、プロジェクトのAI対応状況を評価してレポートを生成できるよう支援します。プロジェクトがAIツールをどの程度活用できる状態にあるかを把握するのに役立ちます。
acreadiness-generate-instructions
40kエージェントが、評価結果をもとにAIツール向けの指示文を作成できるよう支援します。AIがコードとどのようにやり取りするかを改善し、特定された不足点を解消するのに役立ちます。
acreadiness-policy
40kエージェントが、AIプロジェクトの評価ポリシーの策定や適用を支援できるようにします。プロジェクトの評価方法を標準化し、コンプライアンスを確保するのに役立ちます。
似ているスキル
openclaw-update
394k既存のOpenClaw Gatewayを更新するようエージェントを支援します。インストール方法に合った更新方法を選び、セッションを動かし続けます。
diagnose-gateway
394k設定、チャンネル、ポートを確認して、OpenClaw Gatewayが失敗している理由を、何も変更せずに突き止めるようエージェントを支援します。
crabbox-apps
394k一時的なクラウドマシン上でアプリを開いて実行し、そのビューをチャットのサイドパネルに表示するようエージェントを支援します。