From agent-almanac
Generates production-ready Dockerfiles for Node.js, Python, Go, Rust, and Java projects with base image selection, dependency install, user permissions, and .dockerignore.
How this skill is triggered — by the user, by Claude, or both
Slash command
/agent-almanac:create-dockerfileThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Write a production-ready Dockerfile for general-purpose application projects.
Write a production-ready Dockerfile for general-purpose application projects.
npm start, python app.py)| Language | Dev Image | Prod Image | Size |
|---|---|---|---|
| Node.js | node:22-bookworm | node:22-bookworm-slim | ~200MB |
| Python | python:3.12-bookworm | python:3.12-slim-bookworm | ~150MB |
| Go | golang:1.23-bookworm | gcr.io/distroless/static | ~2MB |
| Rust | rust:1.82-bookworm | debian:bookworm-slim | ~80MB |
| Java | eclipse-temurin:21-jdk | eclipse-temurin:21-jre | ~200MB |
Expected: Select the slim/distroless variant for production images.
FROM node:22-bookworm-slim
RUN groupadd -r appuser && useradd -r -g appuser -m appuser
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY . .
USER appuser
EXPOSE 3000
CMD ["node", "src/index.js"]
FROM python:3.12-slim-bookworm
RUN groupadd -r appuser && useradd -r -g appuser -m appuser
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
USER appuser
EXPOSE 8000
CMD ["python", "app.py"]
FROM golang:1.23-bookworm AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /app/server ./cmd/server
FROM gcr.io/distroless/static
COPY --from=builder /app/server /server
EXPOSE 8080
ENTRYPOINT ["/server"]
FROM rust:1.82-bookworm AS builder
WORKDIR /src
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release && rm -rf src
COPY . .
RUN touch src/main.rs && cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /src/target/release/myapp /usr/local/bin/myapp
EXPOSE 8080
ENTRYPOINT ["myapp"]
FROM eclipse-temurin:21-jdk AS builder
WORKDIR /src
COPY pom.xml .
RUN mvn dependency:go-offline -B
COPY src ./src
RUN mvn package -DskipTests
FROM eclipse-temurin:21-jre
COPY --from=builder /src/target/*.jar /app/app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
Expected: docker build -t myapp . completes without errors.
On failure: Check base image availability and dependency installation commands.
| Directive | Purpose | Override |
|---|---|---|
ENTRYPOINT | Fixed executable | Override with --entrypoint |
CMD | Default arguments | Override with trailing args |
| Both | ENTRYPOINT + default args via CMD | Args override CMD only |
Use ENTRYPOINT for compiled binaries with a single purpose. Use CMD for interpreted languages where you might want docker run myapp bash.
.git
.gitignore
node_modules
__pycache__
*.pyc
target/
.env
.env.*
*.md
!README.md
.vscode
.idea
Dockerfile
docker-compose*.yml
Expected: Build context excludes development artifacts.
Always run as non-root in production:
RUN groupadd -r appuser && useradd -r -g appuser -m appuser
USER appuser
For distroless images, use the built-in nonroot user:
FROM gcr.io/distroless/static:nonroot
USER nonroot
docker build -t myapp:latest .
docker run --rm myapp:latest
docker image inspect myapp:latest --format '{{.Size}}'
Expected: Container starts, responds on the expected port, runs as non-root.
On failure: Check logs with docker logs. Verify WORKDIR, COPY paths, and exposed ports.
docker build completes without errors.dockerignore excludes unnecessary files.env files baked into the imagenode_modules or .git into the build context wastes time and disk.latest tag for base images: Pin to specific versions (e.g., node:22.11.0) for reproducibility.--no-cache-dir: Python pip caches packages by default, bloating the image.COPY unless you need URL download or tar extraction (ADD auto-extracts).create-r-dockerfile - R-specific Dockerfile using rocker imagescreate-multistage-dockerfile - multi-stage patterns for minimal production imagesoptimize-docker-build-cache - advanced caching strategiessetup-compose-stack - orchestrate the containerized app with other servicesnpx claudepluginhub pjt222/agent-almanacGenerates optimized multi-stage Dockerfiles for Node.js, Python, Rust, Go apps with non-root users, layer caching, health checks, and .dockerignore. Use for containerizing apps or Docker Compose setup.
This skill should be used when the user says "create Dockerfile", "dockerize project", "Docker packaging", "container setup", "multi-stage build", "Docker Compose", "containerize application", "create docker-compose.yml", "create .dockerignore", "optimize Docker image", or wants to containerize their project or create Docker configurations.
Generates optimized multi-stage Dockerfiles, .dockerignore, for Node.js, Python, Go, Java apps with security hardening, layer caching, validation, and error fixes.