Generate dockerfile
Skill svyatov/agent-toolkit/plugins/generate-dockerfile/skills/generate-dockerfile
Personal agent toolkit — reusable skills and plugins for Claude Code, Cursor, Codex, and Gemini CLI
npx -y skills add svyatov/agent-toolkit --skill generate-dockerfileAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Generate optimized, secure, multi-stage Dockerfiles and .dockerignore files for any project. Use when the user asks to: (1) containerize a project, (2) create or generate a Dockerfile, (3) improve or optimize an existing Dockerfile, (4) add Docker support to a project, (5) review a Dockerfile for best practices. Also use when the user wants to make something deployable, set up containers, or ship an app — even without mentioning Docker explicitly. Triggers on: "Dockerfile", "dockerize", "containerize", "Docker build", "docker image", ".dockerignore", "make this deployable", "container setup", "production-ready setup", "ship this app".
SKILL.md
5.8 KB, as published. Nobody here has run it
Generate Production-Ready Dockerfile
Generate an optimized, secure, multi-stage Dockerfile and .dockerignore by analyzing the project's structure, language, framework, and dependencies.
Critical Rules
Verify Everything Before Adding
Before adding ANY instruction to the Dockerfile, verify it by examining the actual codebase — read actual source files (not just file names), search with multiple queries, trace the application entry point through imports. Shallow analysis produces broken Dockerfiles; if the analysis felt quick, something was probably missed. Never assume — if uncertain, ask the user.
Multi-Architecture Support
Ensure all instructions support multiple architectures (amd64, arm64). Use multi-arch official images. Detect architecture dynamically for binary downloads—never hardcode amd64/x86_64.
Skip HEALTHCHECK
Health endpoints are application-specific and cannot be verified from codebase analysis alone. Adding unverified health checks causes containers to be marked unhealthy incorrectly — so don't add HEALTHCHECK to generated Dockerfiles.
Process
Step 0: Check for Existing Files
Check for Dockerfile (and variants like Dockerfile.prod) and .dockerignore in the project root. Read them if present—this determines whether to generate new files or improve existing ones.
Step 1: Analyze Project
Investigate the actual project (do not pattern-match). For each item, search the codebase for evidence:
- Language — Find dependency manifests (
package.json,go.mod,requirements.txt,Cargo.toml,Gemfile, etc.). Read their contents. - Version — Check manifests for version constraints, version files (
.node-version,.python-version,.tool-versions), CI configs. If no version found, search online for current LTS/stable. - Framework — Read dependency lists, look for framework config files and directory conventions.
- Application type — Examine entry points: web server (HTTP/routes/port binding), CLI (arg parsing), worker (queue consumers), static site (build output, no server).
- Port — Search for
PORTenv var usage, hardcoded ports in server init, config files. Only add EXPOSE with concrete evidence. - Build requirements — Read manifest for build scripts, identify build tool and outputs.
- System dependencies — Search for code executing external commands (shell exec, subprocess, system calls). For each binary, verify it's needed at runtime vs. build time. Ask user when uncertain.
- Environment variables — Search for env var access patterns,
.env.example/.env.samplefiles, config/startup code. Determine required (no default) vs. optional (has default). Set sensible defaults for required vars.
Step 2: Generate or Improve Dockerfile
Consult references/best-practices.md for detailed patterns, checklists, and package installation examples.
New Dockerfile → Generate multi-stage build following the builder/runtime stage patterns in the reference.
Existing Dockerfile → Evaluate against checklists, identify issues, preserve intentional customizations, edit to fix. Briefly explain changes.
Follow the patterns and checklists in the reference file.
Step 3: Create or Improve .dockerignore
Generate a minimal .dockerignore (~10-15 lines). Since the Dockerfile uses explicit COPY:
- Review Dockerfile COPY commands — what directories are copied?
- Exclude secret patterns that could exist inside copied directories
- Exclude large directories (>1MB) that slow context transfer
- Do NOT exclude directories not copied by the Dockerfile
Step 4: Build, Test, and Iterate
Validate before presenting to user. First verify Docker is available (docker info). If Docker is not installed or not running, skip validation — present the Dockerfile with a note that it hasn't been tested.
- Build the image, then run a detached container from it. Services should stay running; CLI tools should exit with code 0.
- Read the container logs and use the project knowledge from Step 1 to judge whether they indicate success or failure.
- Lint and scan if the tools are installed:
hadolint Dockerfile,trivy image --severity HIGH,CRITICAL <image>. - Iterate — max 5 attempts. If still failing, present the current state with an explanation and ask for guidance.
- Clean up the test container and image afterward, even when validation failed.
Output
New Dockerfile: Present Dockerfile + .dockerignore with brief explanation of key design choices, build/run commands, and image size expectations.
Improved Dockerfile: Present improved version with summary of changes (what + why), note preserved customizations.
Both cases — recommended next steps: integrate into CI/CD, commit to version control.
Final Check
Before presenting, verify the Dockerfile against the Security, Build Optimization, and Stage Pattern checklists in references/best-practices.md — plus the rules above: no HEALTHCHECK, minimal .dockerignore, validation artifacts cleaned up.
Gives 1 of the 12 instructions most containers cloud skills give
Counted across 607 of the 657 authors here whose files we hold, read 2026-08-06
- run containers as a non-root userin 69 of 607, across 49 files
- use multi-stage buildsin 52 of 607, across 41 files
- use Promise.all for independent operationsin 47 of 607, across 13 files
- import directly instead of barrel filesin 46 of 607, across 12 files
- use ternary instead of AND for conditionalsin 45 of 607, across 12 files
- use Set or Map for O(1) lookupsin 42 of 607, across 10 files
- create a .dockerignore filehere, and in 41 of 607, across 31 files
- Read individual rule files for detailsin 39 of 607, across 9 files
- authenticate server actions like API routesin 35 of 607, across 7 files
- use next/dynamic for heavy componentsin 34 of 607, across 9 files
- use React.cache for per-request deduplicationin 34 of 607, across 10 files
- copy dependency files before source codein 34 of 607, across 21 files
Said here and by no other author read
- verify instructions by reading source files
- ensure all instructions support multiple architectures
- check for existing Dockerfiles
- analyze the project for evidence
- build and run a detached test container
- read and validate container logs
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.