docker-scaffold
Scaffold a production-ready Dockerfile and docker-compose.yml for a project — multi-stage builds, non-root user, health checks, and .dockerignore
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffold a production-ready Dockerfile and docker-compose.yml for a project — multi-stage builds, non-root user, health checks, and .dockerignore
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Health check procedures D1–D14 for the Audit agent — structural validation, attention budget, version checks, workspace integrity, and static audit
Configure and manage Model Context Protocol servers for external tool access
Review a UI for accessibility — WCAG 2.1 AA compliance, semantic HTML, ARIA usage, keyboard navigation, focus management, colour contrast, and screen reader compatibility
Design or review a REST or GraphQL API — resource modeling, versioning strategy, error contract, OpenAPI/schema-first workflow, and security baseline
Generate a CHANGELOG.md entry from staged changes, a commit range, or a PR diff — following Keep a Changelog format with conventional commit classification
Set up and audit environment variable management — create .env.example, add startup validation, separate secrets from config, and document every variable
| name | docker-scaffold |
| description | Scaffold a production-ready Dockerfile and docker-compose.yml for a project — multi-stage builds, non-root user, health checks, and .dockerignore |
| compatibility | >=0.7.0 |
Skill metadata: version "1.0"; license MIT; tags [docker, containers, compose, devops, scaffold]; compatibility ">=0.7.0"; recommended tools [codebase, editFiles, runCommands].
Generate a production-quality Dockerfile and docker-compose.yml for any project stack. Includes multi-stage builds, non-root execution, health checks, and a .dockerignore to keep images lean.
Read package.json, requirements.txt, Cargo.toml, go.mod, pom.xml, or build.gradle to determine:
npm start, gunicorn, ./myapp, java -jar app.jar| Runtime | Build stage | Run stage |
|---|---|---|
| Node.js | node:22-alpine | node:22-alpine |
| Python | python:3.13-slim | python:3.13-slim |
| Go | golang:1.23-alpine | gcr.io/distroless/static |
| Rust | rust:1.80-alpine | gcr.io/distroless/cc |
| Java | eclipse-temurin:21-jdk-alpine | eclipse-temurin:21-jre-alpine |
Always prefer Alpine or distroless for the run stage.
Use a multi-stage build. Template:
# syntax=docker/dockerfile:1
### Stage 1: build dependencies
FROM <build-image> AS deps
WORKDIR /app
COPY <manifest files> ./
RUN <install command>
### Stage 2: build application
FROM deps AS builder
COPY . .
RUN <build command>
### Stage 3: production runtime
FROM <runtime-image> AS runtime
# Non-root user
RUN addgroup --system app && adduser --system --ingroup app app
WORKDIR /app
# Copy only built artefacts
COPY --from=builder --chown=app:app /app/<dist> ./
USER app
EXPOSE <port>
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD <health check command>
CMD [<entrypoint>]
Fill in the template with values from step 1. Never use latest tags.
.dockerignore# Version control
.git
.gitignore
# Dependencies (rebuilt in container)
node_modules/
__pycache__/
.venv/
target/
vendor/
# Test and dev artefacts
*.test
coverage/
.pytest_cache/
dist/
build/
# Local config
.env
.env.*
*.local
# IDE
.vscode/
.idea/
*.swp
# Docker
Dockerfile*
docker-compose*
.dockerignore
docker-compose.ymlFor local development:
services:
app:
build:
context: .
target: runtime
ports:
- "127.0.0.1:<port>:<port>"
environment:
- NODE_ENV=development # or equivalent
env_file:
- .env
volumes:
- .:/app:cached # remove for production
restart: unless-stopped
healthcheck:
test: [<health check>]
interval: 30s
timeout: 5s
retries: 3
# Add database/cache services as needed
# db:
# image: postgres:17-alpine
# ...
ARG/ENV for build-time values, .env for runtime)--no-cache or --no-install-recommends flags used for package managers.dockerignore excludes .env, node_modules, .git127.0.0.1 in compose (not 0.0.0.0 unless intentional)docker build -t myapp .
docker run --rm -p <port>:<port> myapp
# Confirm health check passes
docker inspect --format='{{.State.Health.Status}}' <container>
HEALTHCHECK instruction present.dockerignore prevents .env and dependency directories from entering the image