20 specialized agents, 10 skills, 17 slash commands, 6 plugins, 12 hooks with scripts, 8 rule sets, 3 CLAUDE.md templates, 14 MCP server configs, and interactive setup installer.
2.8 KiB
2.8 KiB
/deploy-pilot:dockerfile
Generate an optimized multi-stage Dockerfile for the current project.
Process
-
Detect the project type and runtime:
- Check for
package.json(Node.js),requirements.txt/pyproject.toml(Python),go.mod(Go),Cargo.toml(Rust),pom.xml/build.gradle(Java) - Identify the framework (Next.js, FastAPI, Gin, Actix, Spring Boot, etc.)
- Read the existing entrypoint script or start command
- Check for
-
Select the appropriate base image:
- Use official slim/alpine variants for smaller image sizes
- Pin to a specific version tag, never use
latest - For Node.js:
node:22-alpinefor runtime,node:22for build - For Python:
python:3.12-slimfor runtime - For Go:
golang:1.23-alpinefor build,gcr.io/distroless/static-debian12for runtime - For Rust:
rust:1.82-slimfor build,debian:bookworm-slimfor runtime
-
Structure the Dockerfile with these stages:
Stage 1: Dependencies
- Copy only dependency manifests (package.json, go.sum, Cargo.lock, etc.)
- Install dependencies in a cached layer
- This stage changes only when dependencies change, maximizing cache hits
Stage 2: Build
- Copy source code
- Run the build command (compile, transpile, bundle)
- Run tests if a
--with-testsflag is specified - Prune dev dependencies after build
Stage 3: Runtime
- Start from a minimal base image
- Copy only the built artifacts and production dependencies
- Set a non-root user for security
- Configure health check with appropriate endpoint or command
- Set resource limits via labels where applicable
- Define the entrypoint and default command
-
Apply these optimizations:
- Order COPY instructions from least to most frequently changed
- Use
.dockerignorepatterns: suggest creating one if missing - Set
NODE_ENV=productionor equivalent environment variables - Use
COPY --from=buildto minimize final image layers - Add
LABELinstructions for maintainer, version, and description - Set
EXPOSEfor the application port - Use
tiniordumb-initas PID 1 for proper signal handling in Node.js
-
Generate a companion
.dockerignoreif one does not exist, including:.git,node_modules,__pycache__,.env,*.log- Build output directories, test fixtures, documentation
Output
Write the Dockerfile to the project root. If a Dockerfile already exists, present a diff and ask before overwriting. Include inline annotations explaining each optimization decision.
Rules
- Never hardcode secrets or credentials in the Dockerfile
- Always run as non-root in the final stage
- Keep the final image under 200MB when possible
- Support both amd64 and arm64 architectures (avoid platform-specific binaries)
- Test the Dockerfile with
docker build --target runtime .if Docker is available