skills/dockerfile-generation/SKILL.md
Use when creating Dockerfiles, optimizing container images, or reviewing Docker configurations. Produces multi-stage, security-hardened builds with proper layer caching. Triggers on 'create Dockerfile', 'dockerize', 'optimize container'.
npx skillsauth add dtsong/my-claude-setup dockerfile-generationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate production-ready Dockerfiles through iterative verification.
docker build and docker run for verification only — no deployment or registry push.. traversal and null bytes:latestBefore writing ANY Dockerfile instruction, verify:
[ ] Language/runtime detected (package.json, requirements.txt, go.mod, etc.)
[ ] Entry point identified (main file, start script)
[ ] Build command identified (if compilation needed)
[ ] Dependencies file location confirmed
[ ] Required environment variables documented
[ ] Exposed ports identified from code (NOT assumed)
Structure:
# syntax=docker/dockerfile:1
# Build stage
FROM <base>:<pinned-version> AS builder
WORKDIR /app
# Install deps first (cache layer)
COPY <deps-file> .
RUN <install-deps>
# Copy source
COPY . .
RUN <build-command>
# Runtime stage
FROM <minimal-base>:<pinned-version>
WORKDIR /app
# Security: non-root user
RUN addgroup --gid 10001 appgroup && \
adduser --uid 10001 --ingroup appgroup --disabled-password appuser
USER appuser
# Copy artifacts from builder
COPY --from=builder --chown=appuser:appgroup /app/<artifact> .
EXPOSE <verified-port>
CMD ["<verified-entrypoint>"]
Language-specific bases:
| Language | Builder | Runtime |
|----------|---------|---------|
| Node.js | node:<version>-alpine | node:<version>-alpine |
| Python | python:<version>-slim | python:<version>-slim |
| Go | golang:<version>-alpine | gcr.io/distroless/static |
| Java | eclipse-temurin:<version> | eclipse-temurin:<version>-jre-alpine |
| Rust | rust:<version>-alpine | gcr.io/distroless/cc |
# Build
docker build -t test-image:local .
# Run and capture logs
docker run --rm test-image:local 2>&1 | head -50
# If error: analyze → fix → rebuild
# If success: verify functionality
Stop conditions:
COPY . . before COPY package*.json && npm install busts the dependency cache on every source change — always copy deps files firstmusl not glibc — native Node.js addons (bcrypt, sharp) may fail with cryptic errors. Use -slim for compatibilityRUN apt-get update && apt-get install without rm -rf /var/lib/apt/lists/* bloats the image by 30-100MBCOPY --from=builder — forgetting to copy a config file causes silent runtime failuresEXPOSE is documentation only — it does NOT publish the port. You still need -p at runtimeFROM <image>:latest - Always pin versionsRUN apt-get update && apt-get install without cleanupCOPY . . before dependency installationWhen generating a Dockerfile, output:
development
Use when the council needs to surface organizational knowledge buried across multiple internal sources (wikis, design docs, ADRs, past tickets, postmortems, chat archives, code repos). Plans where to look, what to cross-reference, and how to synthesize findings into evidence the council can act on. Do not use for external market research (use competitive-analysis), library evaluation (use library-evaluation), or technology trend assessment (use technology-radar).
testing
Use to convert a Word .docx file to PDF and/or verify its page count. Triggers on: converting docx to pdf, rendering a document, checking how many pages a docx produces, or asserting a page-count constraint (e.g. a resume must stay 2 pages). Wraps LibreOffice headless conversion.
development
Security audit checklist for web applications. Use when reviewing, auditing, or hardening a web app's security posture. Covers rate limiting, auth headers, IP blocking, CORS, security middleware, input validation, file upload limits, ORM usage, and password hashing. Triggers on requests like "review security", "harden this app", "security audit", "check for vulnerabilities", or when building/reviewing API endpoints.
development
Interactive wizard to craft effective prompts using Claude Code best practices