Claude-skill-registry dockerfile-helper
Dockerfile の作成・改善を支援する。「Dockerfile を作って」「Dockerfile 作成」「Dockerfile をレビュー」「Dockerfile 改善」「Dockerfile 最適化」「マルチステージビルド」「alpine 化」「イメージサイズ削減」「Dockerfile のベストプラクティス」などで起動。
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/dockerfile-helper" ~/.claude/skills/majiayu000-claude-skill-registry-dockerfile-helper && rm -rf "$T"
manifest:
skills/data/dockerfile-helper/SKILL.mdsource content
Dockerfile Helper
Dockerfile の作成・改善を支援します。
対応操作
| 操作 | トリガー例 |
|---|---|
| 新規作成 | 「Dockerfile を作って」「Dockerfile 作成」 |
| レビュー | 「Dockerfile をレビュー」「Dockerfile 改善」 |
| 最適化 | 「マルチステージビルド」「alpine 化」「サイズ削減」 |
実行手順
1. 意図の判定
- 新規作成: 「作って」「作成」「生成」→ 新しい Dockerfile を作成
- レビュー/改善: 「レビュー」「改善」「チェック」→
に委譲/shiiman-docker:lint - 最適化: 「最適化」「alpine」「マルチステージ」「サイズ削減」→ 既存 Dockerfile を最適化
2. 新規作成の場合
プロジェクトの言語/フレームワーク特定
ls package.json go.mod requirements.txt Gemfile pom.xml build.gradle Cargo.toml 2>/dev/null
言語別テンプレート生成
Node.js (
package.json 検出時):
# Build stage FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci # Production stage FROM node:20-alpine RUN addgroup -S app && adduser -S app -G app WORKDIR /app COPY --from=builder /app/node_modules ./node_modules COPY . . USER app EXPOSE 3000 CMD ["node", "index.js"]
Go (
go.mod 検出時):
# Build stage FROM golang:1.22-alpine AS builder WORKDIR /app COPY go.* ./ RUN go mod download COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -o main . # Production stage FROM scratch COPY --from=builder /app/main /main ENTRYPOINT ["/main"]
Python (
requirements.txt 検出時):
# Build stage FROM python:3.12-slim AS builder WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir --target=/app/deps -r requirements.txt # Production stage FROM python:3.12-slim RUN useradd -m -r app WORKDIR /app ENV PYTHONPATH=/app/deps COPY --from=builder /app/deps /app/deps COPY . . USER app CMD ["python", "main.py"]
.dockerignore も同時に作成
.git .gitignore README.md Dockerfile* docker-compose* .env* *.log node_modules __pycache__ *.pyc .pytest_cache coverage .coverage dist build *.egg-info
3. レビュー/改善の場合
/shiiman-docker:lint コマンドに委譲(SSOT):
レビューを実行するには `/shiiman-docker:lint` を使用します。
4. 最適化の場合
既存の Dockerfile を読み込み、以下の観点で最適化:
マルチステージビルド化
単一ステージの Dockerfile をマルチステージに変換:
# Before FROM node:20 WORKDIR /app COPY . . RUN npm install CMD ["npm", "start"] # After FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci --only=production FROM node:20-alpine WORKDIR /app COPY --from=builder /app/node_modules ./node_modules COPY . . CMD ["npm", "start"]
alpine 化
フルイメージを alpine に変更:
| Before | After | サイズ削減 |
|---|---|---|
| | ~900MB → ~180MB |
| | ~1GB → ~150MB |
| | ~800MB → ~250MB |
レイヤー最適化
# Before RUN apt-get update RUN apt-get install -y curl RUN apt-get install -y git RUN rm -rf /var/lib/apt/lists/* # After RUN apt-get update && \ apt-get install -y --no-install-recommends \ curl \ git && \ rm -rf /var/lib/apt/lists/*
5. 出力フォーマット
## Dockerfile 作成完了 **ファイル**: Dockerfile **ベースイメージ**: {base_image} **ステージ数**: {stages} **推定サイズ**: {estimated_size} ### 特徴 - ✅ マルチステージビルド - ✅ 非 root ユーザー - ✅ alpine ベースイメージ - ✅ .dockerignore 同梱 ### 次のステップ 1. `docker build -t myapp .` でビルド 2. `docker run -p 3000:3000 myapp` で実行
注意事項
- ✅ マルチステージビルドを推奨
- ✅ alpine/slim イメージを推奨
- ✅ 非 root ユーザーでの実行を推奨
- ✅ .dockerignore を同時に作成
- ✅ レビューは
に委譲(SSOT)/shiiman-docker:lint - ❌ 機密情報をハードコードしない