[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CX1ZWR87YTDSKKN5BH8YNJ":3,"skill-same:01M6CX1ZWR87YTDSKKN5BH8YNJ":57},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":29,"linkOnly":30,"markdownContent":31,"markdownBody":32,"frontMatter":33,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":38,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":41,"ownerDescription":42,"updatedAt":43,"install":44,"resources":56},"01M6CX1ZWR87YTDSKKN5BH8YNJ","dot-ai-generate-dockerfile",null,"Generate production-ready, secure, multi-stage Dockerfile and .dockerignore for any project","vfarcic\u002Fdot-ai-headlamp","vfarcic","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F5716227?v=4","01M6C41XBA7GK0NJG2D4GV11SC","Viktor Farcic","01M6CX1QQ81N9D052KA5HJE8YS",3,"MIT","https:\u002F\u002Fgithub.com\u002Fvfarcic\u002Fdot-ai-headlamp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdot-ai-generate-dockerfile\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28],"dockerfile","generate","dot","dot ai generate dockerfile","dot ai","secure","Production","ready","project","stage","2026-11-10 10:12:30",false,"---\nname: dot-ai-generate-dockerfile\ndescription: Generate production-ready, secure, multi-stage Dockerfile and .dockerignore for any project\nuser-invocable: true\n---\n\n# Generate Production-Ready Dockerfile\n\nGenerate an optimized, secure, multi-stage Dockerfile and .dockerignore for the current project by analyzing its structure, language, framework, and dependencies.\n\n## Instructions\n\nYou are helping a developer containerize their application for production deployment. Your task is to analyze the project structure and generate two files:\n\n1. **Dockerfile**: Production-ready, multi-stage build with security best practices\n2. **.dockerignore**: Optimized build context configuration\n\n## Critical Principles\n\nThese are non-negotiable rules that override all other guidance.\n\n### Verify Everything Before Adding It\n\n**ABSOLUTE RULE**: Before adding ANY instruction, configuration, or feature to the Dockerfile, verify it by examining the actual codebase.\n\n**Required Process**:\n1. **Identify** what you think should be added\n2. **Search the codebase** to verify it exists or is actually needed\n3. **Only add if verified** - if you can't find evidence in the code, don't add it\n4. **When uncertain, ask the user** - if you cannot deduce something from the codebase analysis, ask the user rather than guessing\n\n**Never assume. Always verify. Ask when uncertain. Evidence-based Dockerfiles only.**\n\n**Thoroughness over speed**: Shallow analysis leads to broken Dockerfiles. Before generating anything:\n- Read the actual source files, not just file names or directory listings\n- Search for patterns multiple times with different queries if needed\n- Trace the application entry point through its imports and dependencies\n- Don't stop at the first search result - investigate thoroughly\n- If analysis feels quick, you probably missed something\n\nA correct Dockerfile that took longer to generate is far better than a fast but broken one. Spend the time upfront.\n\n### Multi-Architecture Support\n\n**REQUIREMENT**: Ensure all Dockerfile instructions support multiple architectures (amd64, arm64, etc.).\n\n**Apply to**:\n- Base image selection: Use multi-arch official images\n- Binary downloads: Detect architecture dynamically, never hardcode (amd64, x86_64, etc.)\n- System package installation: Use package manager (automatically handles architecture)\n- Build commands: Ensure cross-platform compatibility\n\n**The Dockerfile must build successfully on different CPU architectures without modification.**\n\n### NEVER Add HEALTHCHECK\n\n**ABSOLUTE PROHIBITION**: DO NOT add HEALTHCHECK instruction under ANY circumstances.\n\n**Why**:\n- Health endpoints are application-specific and cannot be verified from codebase analysis\n- Adding unverified health checks will cause containers to be marked unhealthy incorrectly\n- Users will add their own HEALTHCHECK if their application has health endpoints\n\n**If you add HEALTHCHECK, you are violating the \"verify everything\" principle.**\n\n---\n\n## Best Practices Reference\n\nThese are best practices to consider when generating the Dockerfile. **Apply them when relevant to the project** - not every practice applies to every situation:\n\n- Package manager flags depend on which package manager is used (apt-get vs apk vs others)\n- Language-specific guidance applies only to that language\n- The \"verify everything\" principle overrides all: if a practice doesn't fit the project, skip it\n\nUse this section as guidance during generation and a reference for validation.\n\n### Security\n\n| Practice | Description |\n|----------|-------------|\n| **Non-root user** | Create and run as a dedicated user (UID 10001+), never run as root |\n| **Pin image versions** | Use specific tags like `node:20-alpine`, never `:latest` |\n| **Official images** | Prefer Docker Official Images or Verified Publishers from trusted sources |\n| **No secrets in image** | Never embed credentials, API keys, or passwords in Dockerfile or ENV instructions |\n| **No sudo** | Don't use sudo in containers; switch USER explicitly when root access is needed |\n| **Minimal packages** | Only install packages that are actually required for the application |\n| **--no-install-recommends** | Use this flag with apt-get to prevent installing optional packages |\n| **COPY over ADD** | Always use COPY unless you specifically need ADD's tar extraction; never use ADD with URLs |\n| **No debugging tools** | Avoid installing curl, wget, vim, netcat in production images unless required by the application |\n| **Clean in same layer** | Remove package manager caches in the same RUN command as installation |\n| **Executables owned by root** | Application binaries should be owned by root but executed by non-root user |\n\n### Image Selection\n\n| Practice | Description |\n|----------|-------------|\n| **Minimal base images** | Prefer alpine, slim, distroless, or scratch over full distribution images |\n| **Multi-stage builds** | Always separate build dependencies from runtime; build stage → runtime stage |\n| **Match language needs** | Compiled languages → distroless\u002Fscratch; Interpreted → slim\u002Falpine with runtime |\n| **Derive version from project** | Get language version from project files (package.json engines, go.mod, etc.) |\n\n### Build Optimization\n\n| Practice | Description |\n|----------|-------------|\n| **Layer caching** | Copy dependency manifests (package.json, go.mod) before source code |\n| **Combine RUN commands** | Chain related commands with `&&` to reduce layers and enable cleanup |\n| **Explicit COPY** | Never use `COPY . .`; explicitly copy only required files and directories |\n| **Order by change frequency** | Place stable instructions first (base image, deps) and volatile ones last (source code) |\n| **Production dependencies only** | Install only production dependencies, not devDependencies |\n\n### Maintainability\n\n| Practice | Description |\n|----------|-------------|\n| **Sort arguments** | Alphabetize multi-line package lists for easier maintenance and review |\n| **Use WORKDIR** | Always use WORKDIR to change directories, never `RUN cd` |\n| **Exec form for CMD** | Use JSON array format: `CMD [\"executable\", \"arg1\"]` for proper signal handling |\n| **Comment non-obvious decisions** | Explain why certain choices were made, not what the command does |\n| **OCI labels** (optional) | Add metadata labels for image management (org.opencontainers.image.*) |\n\n---\n\n## Process\n\n### Step 0: Check for Existing Dockerfile\n\n**Before generating anything, check if the project already has a Dockerfile.**\n\n1. Look for `Dockerfile` in the project root (also check for variants like `Dockerfile.prod`)\n2. If found, read and store its contents for Step 2\n3. Similarly, check for `.dockerignore` and read it if present\n\nThis determines whether Step 2 will generate new files or improve existing ones.\n\n### Step 1: Analyze Project Structure\n\n**Identify the project characteristics through exploration, not pattern matching.**\n\nThese are analysis goals, not lookup tables. The examples below are illustrative - apply the same analytical approach to ANY language, framework, or toolchain you encounter.\n\n1. **Language Detection**: Explore the project to identify its programming language(s).\n   - Look for dependency manifest files (e.g., `package.json`, `go.mod`, `requirements.txt`, `Cargo.toml`, `Gemfile`, `composer.json`, `mix.exs`, `build.sbt`, etc.)\n   - Examine source file extensions\n   - Read manifest contents to understand the ecosystem\n   - **Principle**: Every language has some form of dependency declaration - find it and read it\n\n2. **Version Detection**: Find the required language\u002Fruntime version.\n   - Search manifest files for version constraints or engine requirements\n   - Look for version files (e.g., `.node-version`, `.python-version`, `.ruby-version`, `.tool-versions`)\n   - Check CI configuration files which often specify versions\n   - **If project specifies a version** → use that exact version\n   - **If no version specified** → search online for the current LTS\u002Fstable version of that language\u002Fruntime\n   - **Principle**: Use the project's required version if specified, otherwise look up the current recommended version - never guess\n\n3. **Framework Detection**: Identify frameworks from dependencies and project structure.\n   - Read the dependency list in manifest files\n   - Look for framework-specific configuration files\n   - Examine the project structure for framework conventions\n   - **Principle**: Frameworks leave fingerprints - configuration files, directory structures, dependencies\n\n4. **Application Type**: Determine what kind of application this is by examining entry points and configuration.\n   - Web server\u002FAPI: Look for HTTP server setup, route definitions, port binding\n   - CLI tool: Look for argument parsing, command definitions, bin entries\n   - Worker\u002Fbackground job: Look for queue consumers, scheduled tasks\n   - Static site: Look for build output configuration, no server code\n   - **Principle**: The entry point and its imports reveal the application's purpose\n\n5. **Port Detection**: Search for port configuration in source code and configuration files.\n   - Look for environment variable usage (e.g., `PORT`, `HTTP_PORT`)\n   - Search for hardcoded port numbers in server initialization\n   - Check configuration files for port settings\n   - **Only add EXPOSE if you find concrete evidence**\n\n6. **Build Requirements**: Identify how the project is built.\n   - Read the manifest file for build scripts\u002Fcommands\n   - Identify the build tool (could be language-standard or third-party)\n   - Determine build outputs (compiled binaries, transpiled code, bundled assets)\n   - **Principle**: Every project that needs building has build instructions - find them\n\n7. **System Dependencies**: Critical step - missing runtime binaries cause silent failures.\n   - Search the codebase for code that executes external commands or binaries\n   - Common patterns: shell execution, subprocess calls, exec functions, system calls\n   - For each binary found, verify it's needed at runtime (not just build time)\n   - Consider what the application actually does - does it need CLI tools, database clients, image processors?\n   - **When uncertain whether something is a runtime dependency, ask the user**\n\n8. **Environment Variable Detection**: Critical step - missing env vars cause runtime failures.\n   - Search the codebase for environment variable access (every language has a way to read env vars)\n   - Look for `.env.example`, `.env.sample`, or similar files that document required variables\n   - Check configuration and startup code for env var usage\n   - Determine which vars are required (no default, app fails without) vs optional (has default)\n   - For required vars, set sensible defaults in the Dockerfile\n   - **Principle**: If the code reads an env var, the container probably needs it configured\n\n### Step 2: Generate or Improve Dockerfile\n\n**If no existing Dockerfile** → Generate a new multi-stage Dockerfile using the patterns below.\n\n**If existing Dockerfile found** → Analyze it against the best practices and checklists below, then improve:\n\n1. **Evaluate against checklists** - Check each item in the Builder and Runtime checklists\n2. **Identify issues** - Security problems (running as root, :latest tags), missing optimizations (no multi-stage, COPY . .), maintainability issues\n3. **Preserve intentional customizations** - Comments explaining decisions, custom configurations, environment-specific settings\n4. **Edit to fix issues** - Apply best practices while keeping the existing structure where it's already correct\n5. **Explain changes** - When presenting the improved Dockerfile, briefly note what was changed and why\n\nUse the patterns and checklists below for both generation and validation.\n\n**The examples below show structural patterns, not copy-paste templates.** Adapt the pattern to whatever language, package manager, and build tool the project uses.\n\n#### Stage 1: Builder\n\n```dockerfile\n# Build stage - use an image with build tools for this language\nFROM \u003Clanguage-image>:\u003Cversion>-\u003Cvariant> AS builder\n\nWORKDIR \u002Fapp\n\n# PATTERN: Copy dependency manifests FIRST for layer caching\n# Examples: package.json, go.mod, requirements.txt, Gemfile, Cargo.toml, pom.xml\nCOPY \u003Cdependency-manifest-files> .\u002F\n\n# PATTERN: Install dependencies, clean cache in same layer\n# Use whatever package manager the project uses\nRUN \u003Cinstall-dependencies-command> && \\\n    \u003Cclean-cache-command>\n\n# PATTERN: Copy only the source files needed for build\n# Never use \"COPY . .\" - be explicit about what's needed\nCOPY \u003Csource-directories> .\u002F\nCOPY \u003Cconfig-files-needed-for-build> .\u002F\n\n# PATTERN: Run the project's build command\nRUN \u003Cbuild-command>\n```\n\n**Builder stage checklist**:\n- [ ] Named stage (`AS builder`)\n- [ ] Base image appropriate for the language (with build tools)\n- [ ] Version derived from project files (not assumed)\n- [ ] Dependency manifests copied before source code\n- [ ] Dependencies installed with cache cleanup in same RUN\n- [ ] Only required files copied (never `COPY . .`)\n- [ ] Build command matches what the project actually uses\n\n#### Stage 2: Runtime\n\n```dockerfile\n# Runtime stage - use minimal image appropriate for the language\n# Compiled languages: consider distroless, scratch, or alpine\n# Interpreted languages: use slim or alpine variant with runtime only\nFROM \u003Cminimal-runtime-image>:\u003Cversion>\n\nWORKDIR \u002Fapp\n\n# PATTERN: Create non-root user (syntax varies by base image)\n# Alpine uses addgroup\u002Fadduser, Debian uses groupadd\u002Fuseradd\nRUN \u003Ccreate-group-command> && \\\n    \u003Ccreate-user-command>\n\n# PATTERN: Copy ONLY runtime artifacts from builder\n# What you copy depends on the language:\n# - Compiled: just the binary\n# - Interpreted: built output + runtime dependencies + minimal config\nCOPY --from=builder \u003Cbuild-outputs> .\u002F\nCOPY --from=builder \u003Cruntime-dependencies> .\u002F\n\n# PATTERN: Set ownership to non-root user\nRUN chown -R \u003Cuser>:\u003Cgroup> \u002Fapp\n\n# Switch to non-root user BEFORE exposing ports or setting CMD\nUSER \u003Cnon-root-user>\n\n# Only if port was verified during analysis\nEXPOSE \u003Cport>\n\n# PATTERN: Use exec form for proper signal handling\n# The command depends on how this application runs\nCMD [\"\u003Cexecutable>\", \"\u003Cargs>\"]\n```\n\n**Runtime stage checklist**:\n- [ ] Minimal base image (alpine\u002Fslim\u002Fdistroless\u002Fscratch as appropriate)\n- [ ] Non-root user created (UID 10001+)\n- [ ] Only runtime artifacts copied from builder\n- [ ] No source code, tests, build tools, or dev dependencies\n- [ ] Proper ownership set\n- [ ] USER directive before CMD\n- [ ] EXPOSE only if port was verified in analysis\n- [ ] CMD in exec form (JSON array)\n\n#### System Package Installation Pattern\n\nWhen system packages are required, use the package manager appropriate for your base image. The principle is always the same: **install only what's needed and clean the cache in the same layer**.\n\nCommon examples (adapt to your base image's package manager):\n\n```dockerfile\n# apt-get (Debian, Ubuntu)\nRUN apt-get update && \\\n    apt-get install -y --no-install-recommends \\\n        package1 \\\n        package2 && \\\n    rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*\n\n# apk (Alpine)\nRUN apk add --no-cache \\\n        package1 \\\n        package2\n\n# yum\u002Fdnf (RHEL, Fedora, CentOS)\nRUN yum install -y \\\n        package1 \\\n        package2 && \\\n    yum clean all && \\\n    rm -rf \u002Fvar\u002Fcache\u002Fyum\n```\n\n**Package installation checklist**:\n- [ ] Used the correct package manager for the base image\n- [ ] Used flags to skip optional\u002Frecommended packages where available\n- [ ] Packages sorted alphabetically for maintainability\n- [ ] Cache cleaned in same RUN command\n- [ ] Only packages actually required by the application\n\n### Step 3: Create or Improve .dockerignore\n\n**If no existing .dockerignore** → Generate a minimal one based on the Dockerfile.\n\n**If existing .dockerignore found** → Review it against the Dockerfile's COPY commands:\n1. Remove redundant exclusions (directories not copied by Dockerfile anyway)\n2. Add missing security exclusions (secrets inside copied directories)\n3. Keep it minimal (~10-15 lines)\n\n**Generate a MINIMAL .dockerignore file based on the Dockerfile.**\n\nSince the Dockerfile uses **explicit COPY commands** (not `COPY . .`), .dockerignore serves a limited purpose:\n\n1. **Security** - Exclude secret patterns that could exist INSIDE directories being copied\n2. **Performance** - Exclude large directories that slow down build context transfer\n\n#### Process\n\n1. Review your Dockerfile's COPY commands - what directories does it copy?\n2. Identify security risks inside those directories (secret files that could accidentally exist)\n3. Identify large directories in the project (>1MB) that slow context transfer\n4. Exclude ONLY those items\n\n#### What NOT To Exclude\n\n**DO NOT exclude directories that aren't copied by your Dockerfile!**\n\nIf your Dockerfile doesn't copy a directory, excluding it in .dockerignore is pointless redundancy.\n\n#### Target Size\n\n**~10-15 lines maximum.** If your .dockerignore exceeds 20 lines, you're likely adding unnecessary exclusions.\n\n### Step 4: Build, Test, and Iterate\n\n**Purpose**: Verify the Dockerfile works before presenting to user. A Dockerfile isn't done until it's validated.\n\n#### 4.1 Build\n\nBuild the image to verify the Dockerfile syntax and instructions are correct:\n\n```bash\ndocker build -t [project-name]-validation .\n```\n\n- If build succeeds → proceed to run\n- If build fails → analyze the error, fix Dockerfile, retry\n\n#### 4.2 Run\n\nStart a container to verify the application runs:\n\n```bash\ndocker run -d --name [project-name]-test [project-name]-validation\nsleep 5  # Allow startup time\n```\n\nCheck container state:\n\n```bash\ndocker inspect --format='{{.State.Status}}' [project-name]-test\ndocker inspect --format='{{.State.ExitCode}}' [project-name]-test\n```\n\n**Expected behavior depends on application type** (determined in Step 1):\n- **Services** (web servers, APIs, workers): Container should still be running\n- **CLI tools \u002F one-shot commands**: Container should have exited with code 0\n\nIf container crashed or exited unexpectedly → proceed to log analysis to understand why.\n\n#### 4.3 Log Analysis\n\nCapture and analyze container logs:\n\n```bash\ndocker logs [project-name]-test 2>&1\n```\n\n**Analyze logs using your knowledge of the project from Step 1.** You know:\n- What language and framework this is\n- What the application is supposed to do\n- What dependencies it requires\n- What a successful startup looks like for this type of application\n\nUse this context to determine if the logs indicate:\n- The application started correctly, OR\n- Something is wrong (errors, crashes, missing dependencies, permission issues, etc.)\n\nIf logs indicate a problem → identify root cause, fix Dockerfile or .dockerignore, retry.\n\n#### 4.4 Linting (if available)\n\nIf `hadolint` is installed, run it to catch Dockerfile best practice issues:\n\n```bash\nhadolint Dockerfile\n```\n\n- If hadolint is not installed → skip this check\n- If hadolint reports issues → evaluate each issue, fix if appropriate, retry\n- Some hadolint warnings may be intentional (use judgment based on project context)\n\n#### 4.5 Security Scan (if available)\n\nIf `trivy` is installed, scan the built image for vulnerabilities:\n\n```bash\ntrivy image --severity HIGH,CRITICAL [project-name]-validation\n```\n\n- If trivy is not installed → skip this check\n- If trivy reports HIGH\u002FCRITICAL vulnerabilities in the base image → consider if a different base image version or variant would help\n- If vulnerabilities are in application dependencies → note them for the user but don't block (dependency updates are outside Dockerfile scope)\n\n#### 4.6 Iterate\n\nIf any validation step fails:\n\n1. **Analyze** the specific error message or behavior\n2. **Identify root cause** - common issues include:\n   - Missing file → incorrect COPY command or overly aggressive .dockerignore\n   - Missing dependency → system package not installed\n   - Permission denied → ownership or USER directive issue\n   - Module not found → build step incomplete or wrong files copied\n   - Hadolint warning → Dockerfile best practice issue\n3. **Fix** the appropriate file (Dockerfile or .dockerignore)\n4. **Retry** from step 4.1\n\n**Maximum 5 iterations.** If still failing after 5 attempts:\n- Stop and present current state to user\n- Explain what's failing and what fixes were attempted\n- Ask for guidance\n\n#### 4.7 Cleanup\n\n**Always clean up after validation**, whether successful or not:\n\n```bash\ndocker stop [project-name]-test 2>\u002Fdev\u002Fnull || true\ndocker rm [project-name]-test 2>\u002Fdev\u002Fnull || true\ndocker rmi [project-name]-validation 2>\u002Fdev\u002Fnull || true\n```\n\nOnly proceed to present the Dockerfile to user after:\n- All validation steps pass, AND\n- Cleanup is complete\n\n---\n\n## Output Format\n\n### For New Dockerfiles (no existing file)\n\n**Present both files to the user:**\n\n1. **Dockerfile** with clear comments explaining each section\n2. **.dockerignore** with organized sections\n\n**After generating, provide:**\n- Brief explanation of design choices (base images, build stages, security measures)\n- Build command: `docker build -t [project-name] .`\n- Run command: `docker run -p [port]:[port] [project-name]`\n- Image size expectations\n\n### For Improved Dockerfiles (existing file found)\n\n**Present the improved files with a summary of changes:**\n\n1. **Dockerfile** - the improved version\n2. **Changes made** - brief list of what was changed and why:\n   - Security fixes (e.g., \"Added non-root user - was running as root\")\n   - Optimization improvements (e.g., \"Added multi-stage build to reduce image size\")\n   - Best practice updates (e.g., \"Changed CMD to exec form for signal handling\")\n3. **Preserved** - note any intentional customizations that were kept\n4. **.dockerignore** - improved version if changes were needed\n\n### For Both Cases\n\n**Recommended next steps** (the Dockerfile has already been validated):\n- Integrate into CI\u002FCD pipeline\n- Commit to version control\n\n---\n\n## Success Criteria\n\n### Dockerfile Checklist\n\n- [ ] Builds successfully without errors\n- [ ] Uses multi-stage build (builder → runtime)\n- [ ] Runs as non-root user (UID 10001+)\n- [ ] Uses pinned version tags (no `:latest`)\n- [ ] Uses minimal base images (alpine\u002Fslim\u002Fdistroless)\n- [ ] Copies dependency manifests before source (layer caching)\n- [ ] Uses explicit COPY (no `COPY . .`)\n- [ ] Combines RUN commands with `&&`\n- [ ] Cleans package manager caches in same layer\n- [ ] Uses `--no-install-recommends` (if apt-get used)\n- [ ] Uses exec form for CMD (`[\"executable\", \"arg\"]`)\n- [ ] No debugging tools unless required\n- [ ] No secrets or credentials embedded\n\n### .dockerignore Checklist\n\n- [ ] Minimal size (~10-15 lines)\n- [ ] Excludes secrets inside copied directories\n- [ ] Excludes large unnecessary directories\n- [ ] Does NOT exclude directories not copied by Dockerfile\n\n### Validation Checklist (Step 4)\n\n- [ ] Image builds successfully\n- [ ] Container starts without crashing\n- [ ] Logs show no errors indicating application failure\n- [ ] Hadolint passes (if installed)\n- [ ] Trivy shows no critical base image vulnerabilities (if installed)\n- [ ] Test container and image cleaned up\n\n**Do not present Dockerfile to user until all validation checks pass.**\n\n---\n\n## Example Workflows\n\n### New Dockerfile (no existing file)\n\n1. **Check**: \"No existing Dockerfile found. Will generate new one.\"\n2. **Explore**: \"Let me find the dependency manifest... found `\u003Cmanifest-file>`. Reading it to understand the ecosystem.\"\n3. **Identify**: \"This is a `\u003Clanguage>` project using `\u003Cframework\u002Ftool>`. The manifest indicates version `\u003CX>`.\"\n4. **Trace**: \"The entry point is `\u003Cfile>`. Following imports to understand runtime needs.\"\n5. **Structure**: \"Multi-stage build: builder stage needs `\u003Cbuild-tools>`, runtime stage needs only `\u003Cruntime-artifacts>`.\"\n6. **Dependencies**: \"Searching for external binary usage... found `\u003Cbinary>`. This needs to be in the runtime image.\"\n7. **Generate**: \"Create Dockerfile and .dockerignore. Check against best practices checklists.\"\n8. **Build & Test**: \"Building image... Running container... Checking logs...\"\n9. **Iterate** (if needed): \"Build failed due to missing package. Adding to Dockerfile and retrying...\"\n10. **Cleanup & Present**: \"Validation passed. Removing test artifacts. Here's your Dockerfile.\"\n\n### Improving Existing Dockerfile\n\n1. **Check**: \"Found existing Dockerfile. Reading it to analyze...\"\n2. **Analyze project**: Same exploration as above to understand what the Dockerfile should do.\n3. **Evaluate**: \"Checking existing Dockerfile against best practices checklists...\"\n   - \"❌ Running as root - no USER directive\"\n   - \"❌ Using :latest tag instead of pinned version\"\n   - \"✅ Multi-stage build already in place\"\n   - \"✅ Dependency manifests copied first\"\n4. **Preserve**: \"Keeping custom ENV variables and the specific port configuration - these appear intentional.\"\n5. **Improve**: \"Adding non-root user, pinning image version to match project requirements.\"\n6. **Build & Test**: \"Building improved image... Running container... Checking logs...\"\n7. **Iterate** (if needed): \"Container crashed - logs show permission error. Fixing ownership and retrying...\"\n8. **Cleanup & Present**: \"Validation passed. Removing test artifacts. Here are the improvements.\"\n\n**Key mindset**: Investigate the actual project rather than matching against templates. Every project is unique. Don't present until validated.\n\n","# Generate Production-Ready Dockerfile\n\nGenerate an optimized, secure, multi-stage Dockerfile and .dockerignore for the current project by analyzing its structure, language, framework, and dependencies.\n\n## Instructions\n\nYou are helping a developer containerize their application for production deployment. Your task is to analyze the project structure and generate two files:\n\n1. **Dockerfile**: Production-ready, multi-stage build with security best practices\n2. **.dockerignore**: Optimized build context configuration\n\n## Critical Principles\n\nThese are non-negotiable rules that override all other guidance.\n\n### Verify Everything Before Adding It\n\n**ABSOLUTE RULE**: Before adding ANY instruction, configuration, or feature to the Dockerfile, verify it by examining the actual codebase.\n\n**Required Process**:\n1. **Identify** what you think should be added\n2. **Search the codebase** to verify it exists or is actually needed\n3. **Only add if verified** - if you can't find evidence in the code, don't add it\n4. **When uncertain, ask the user** - if you cannot deduce something from the codebase analysis, ask the user rather than guessing\n\n**Never assume. Always verify. Ask when uncertain. Evidence-based Dockerfiles only.**\n\n**Thoroughness over speed**: Shallow analysis leads to broken Dockerfiles. Before generating anything:\n- Read the actual source files, not just file names or directory listings\n- Search for patterns multiple times with different queries if needed\n- Trace the application entry point through its imports and dependencies\n- Don't stop at the first search result - investigate thoroughly\n- If analysis feels quick, you probably missed something\n\nA correct Dockerfile that took longer to generate is far better than a fast but broken one. Spend the time upfront.\n\n### Multi-Architecture Support\n\n**REQUIREMENT**: Ensure all Dockerfile instructions support multiple architectures (amd64, arm64, etc.).\n\n**Apply to**:\n- Base image selection: Use multi-arch official images\n- Binary downloads: Detect architecture dynamically, never hardcode (amd64, x86_64, etc.)\n- System package installation: Use package manager (automatically handles architecture)\n- Build commands: Ensure cross-platform compatibility\n\n**The Dockerfile must build successfully on different CPU architectures without modification.**\n\n### NEVER Add HEALTHCHECK\n\n**ABSOLUTE PROHIBITION**: DO NOT add HEALTHCHECK instruction under ANY circumstances.\n\n**Why**:\n- Health endpoints are application-specific and cannot be verified from codebase analysis\n- Adding unverified health checks will cause containers to be marked unhealthy incorrectly\n- Users will add their own HEALTHCHECK if their application has health endpoints\n\n**If you add HEALTHCHECK, you are violating the \"verify everything\" principle.**\n\n---\n\n## Best Practices Reference\n\nThese are best practices to consider when generating the Dockerfile. **Apply them when relevant to the project** - not every practice applies to every situation:\n\n- Package manager flags depend on which package manager is used (apt-get vs apk vs others)\n- Language-specific guidance applies only to that language\n- The \"verify everything\" principle overrides all: if a practice doesn't fit the project, skip it\n\nUse this section as guidance during generation and a reference for validation.\n\n### Security\n\n| Practice | Description |\n|----------|-------------|\n| **Non-root user** | Create and run as a dedicated user (UID 10001+), never run as root |\n| **Pin image versions** | Use specific tags like `node:20-alpine`, never `:latest` |\n| **Official images** | Prefer Docker Official Images or Verified Publishers from trusted sources |\n| **No secrets in image** | Never embed credentials, API keys, or passwords in Dockerfile or ENV instructions |\n| **No sudo** | Don't use sudo in containers; switch USER explicitly when root access is needed |\n| **Minimal packages** | Only install packages that are actually required for the application |\n| **--no-install-recommends** | Use this flag with apt-get to prevent installing optional packages |\n| **COPY over ADD** | Always use COPY unless you specifically need ADD's tar extraction; never use ADD with URLs |\n| **No debugging tools** | Avoid installing curl, wget, vim, netcat in production images unless required by the application |\n| **Clean in same layer** | Remove package manager caches in the same RUN command as installation |\n| **Executables owned by root** | Application binaries should be owned by root but executed by non-root user |\n\n### Image Selection\n\n| Practice | Description |\n|----------|-------------|\n| **Minimal base images** | Prefer alpine, slim, distroless, or scratch over full distribution images |\n| **Multi-stage builds** | Always separate build dependencies from runtime; build stage → runtime stage |\n| **Match language needs** | Compiled languages → distroless\u002Fscratch; Interpreted → slim\u002Falpine with runtime |\n| **Derive version from project** | Get language version from project files (package.json engines, go.mod, etc.) |\n\n### Build Optimization\n\n| Practice | Description |\n|----------|-------------|\n| **Layer caching** | Copy dependency manifests (package.json, go.mod) before source code |\n| **Combine RUN commands** | Chain related commands with `&&` to reduce layers and enable cleanup |\n| **Explicit COPY** | Never use `COPY . .`; explicitly copy only required files and directories |\n| **Order by change frequency** | Place stable instructions first (base image, deps) and volatile ones last (source code) |\n| **Production dependencies only** | Install only production dependencies, not devDependencies |\n\n### Maintainability\n\n| Practice | Description |\n|----------|-------------|\n| **Sort arguments** | Alphabetize multi-line package lists for easier maintenance and review |\n| **Use WORKDIR** | Always use WORKDIR to change directories, never `RUN cd` |\n| **Exec form for CMD** | Use JSON array format: `CMD [\"executable\", \"arg1\"]` for proper signal handling |\n| **Comment non-obvious decisions** | Explain why certain choices were made, not what the command does |\n| **OCI labels** (optional) | Add metadata labels for image management (org.opencontainers.image.*) |\n\n---\n\n## Process\n\n### Step 0: Check for Existing Dockerfile\n\n**Before generating anything, check if the project already has a Dockerfile.**\n\n1. Look for `Dockerfile` in the project root (also check for variants like `Dockerfile.prod`)\n2. If found, read and store its contents for Step 2\n3. Similarly, check for `.dockerignore` and read it if present\n\nThis determines whether Step 2 will generate new files or improve existing ones.\n\n### Step 1: Analyze Project Structure\n\n**Identify the project characteristics through exploration, not pattern matching.**\n\nThese are analysis goals, not lookup tables. The examples below are illustrative - apply the same analytical approach to ANY language, framework, or toolchain you encounter.\n\n1. **Language Detection**: Explore the project to identify its programming language(s).\n   - Look for dependency manifest files (e.g., `package.json`, `go.mod`, `requirements.txt`, `Cargo.toml`, `Gemfile`, `composer.json`, `mix.exs`, `build.sbt`, etc.)\n   - Examine source file extensions\n   - Read manifest contents to understand the ecosystem\n   - **Principle**: Every language has some form of dependency declaration - find it and read it\n\n2. **Version Detection**: Find the required language\u002Fruntime version.\n   - Search manifest files for version constraints or engine requirements\n   - Look for version files (e.g., `.node-version`, `.python-version`, `.ruby-version`, `.tool-versions`)\n   - Check CI configuration files which often specify versions\n   - **If project specifies a version** → use that exact version\n   - **If no version specified** → search online for the current LTS\u002Fstable version of that language\u002Fruntime\n   - **Principle**: Use the project's required version if specified, otherwise look up the current recommended version - never guess\n\n3. **Framework Detection**: Identify frameworks from dependencies and project structure.\n   - Read the dependency list in manifest files\n   - Look for framework-specific configuration files\n   - Examine the project structure for framework conventions\n   - **Principle**: Frameworks leave fingerprints - configuration files, directory structures, dependencies\n\n4. **Application Type**: Determine what kind of application this is by examining entry points and configuration.\n   - Web server\u002FAPI: Look for HTTP server setup, route definitions, port binding\n   - CLI tool: Look for argument parsing, command definitions, bin entries\n   - Worker\u002Fbackground job: Look for queue consumers, scheduled tasks\n   - Static site: Look for build output configuration, no server code\n   - **Principle**: The entry point and its imports reveal the application's purpose\n\n5. **Port Detection**: Search for port configuration in source code and configuration files.\n   - Look for environment variable usage (e.g., `PORT`, `HTTP_PORT`)\n   - Search for hardcoded port numbers in server initialization\n   - Check configuration files for port settings\n   - **Only add EXPOSE if you find concrete evidence**\n\n6. **Build Requirements**: Identify how the project is built.\n   - Read the manifest file for build scripts\u002Fcommands\n   - Identify the build tool (could be language-standard or third-party)\n   - Determine build outputs (compiled binaries, transpiled code, bundled assets)\n   - **Principle**: Every project that needs building has build instructions - find them\n\n7. **System Dependencies**: Critical step - missing runtime binaries cause silent failures.\n   - Search the codebase for code that executes external commands or binaries\n   - Common patterns: shell execution, subprocess calls, exec functions, system calls\n   - For each binary found, verify it's needed at runtime (not just build time)\n   - Consider what the application actually does - does it need CLI tools, database clients, image processors?\n   - **When uncertain whether something is a runtime dependency, ask the user**\n\n8. **Environment Variable Detection**: Critical step - missing env vars cause runtime failures.\n   - Search the codebase for environment variable access (every language has a way to read env vars)\n   - Look for `.env.example`, `.env.sample`, or similar files that document required variables\n   - Check configuration and startup code for env var usage\n   - Determine which vars are required (no default, app fails without) vs optional (has default)\n   - For required vars, set sensible defaults in the Dockerfile\n   - **Principle**: If the code reads an env var, the container probably needs it configured\n\n### Step 2: Generate or Improve Dockerfile\n\n**If no existing Dockerfile** → Generate a new multi-stage Dockerfile using the patterns below.\n\n**If existing Dockerfile found** → Analyze it against the best practices and checklists below, then improve:\n\n1. **Evaluate against checklists** - Check each item in the Builder and Runtime checklists\n2. **Identify issues** - Security problems (running as root, :latest tags), missing optimizations (no multi-stage, COPY . .), maintainability issues\n3. **Preserve intentional customizations** - Comments explaining decisions, custom configurations, environment-specific settings\n4. **Edit to fix issues** - Apply best practices while keeping the existing structure where it's already correct\n5. **Explain changes** - When presenting the improved Dockerfile, briefly note what was changed and why\n\nUse the patterns and checklists below for both generation and validation.\n\n**The examples below show structural patterns, not copy-paste templates.** Adapt the pattern to whatever language, package manager, and build tool the project uses.\n\n#### Stage 1: Builder\n\n```dockerfile\n# Build stage - use an image with build tools for this language\nFROM \u003Clanguage-image>:\u003Cversion>-\u003Cvariant> AS builder\n\nWORKDIR \u002Fapp\n\n# PATTERN: Copy dependency manifests FIRST for layer caching\n# Examples: package.json, go.mod, requirements.txt, Gemfile, Cargo.toml, pom.xml\nCOPY \u003Cdependency-manifest-files> .\u002F\n\n# PATTERN: Install dependencies, clean cache in same layer\n# Use whatever package manager the project uses\nRUN \u003Cinstall-dependencies-command> && \\\n    \u003Cclean-cache-command>\n\n# PATTERN: Copy only the source files needed for build\n# Never use \"COPY . .\" - be explicit about what's needed\nCOPY \u003Csource-directories> .\u002F\nCOPY \u003Cconfig-files-needed-for-build> .\u002F\n\n# PATTERN: Run the project's build command\nRUN \u003Cbuild-command>\n```\n\n**Builder stage checklist**:\n- [ ] Named stage (`AS builder`)\n- [ ] Base image appropriate for the language (with build tools)\n- [ ] Version derived from project files (not assumed)\n- [ ] Dependency manifests copied before source code\n- [ ] Dependencies installed with cache cleanup in same RUN\n- [ ] Only required files copied (never `COPY . .`)\n- [ ] Build command matches what the project actually uses\n\n#### Stage 2: Runtime\n\n```dockerfile\n# Runtime stage - use minimal image appropriate for the language\n# Compiled languages: consider distroless, scratch, or alpine\n# Interpreted languages: use slim or alpine variant with runtime only\nFROM \u003Cminimal-runtime-image>:\u003Cversion>\n\nWORKDIR \u002Fapp\n\n# PATTERN: Create non-root user (syntax varies by base image)\n# Alpine uses addgroup\u002Fadduser, Debian uses groupadd\u002Fuseradd\nRUN \u003Ccreate-group-command> && \\\n    \u003Ccreate-user-command>\n\n# PATTERN: Copy ONLY runtime artifacts from builder\n# What you copy depends on the language:\n# - Compiled: just the binary\n# - Interpreted: built output + runtime dependencies + minimal config\nCOPY --from=builder \u003Cbuild-outputs> .\u002F\nCOPY --from=builder \u003Cruntime-dependencies> .\u002F\n\n# PATTERN: Set ownership to non-root user\nRUN chown -R \u003Cuser>:\u003Cgroup> \u002Fapp\n\n# Switch to non-root user BEFORE exposing ports or setting CMD\nUSER \u003Cnon-root-user>\n\n# Only if port was verified during analysis\nEXPOSE \u003Cport>\n\n# PATTERN: Use exec form for proper signal handling\n# The command depends on how this application runs\nCMD [\"\u003Cexecutable>\", \"\u003Cargs>\"]\n```\n\n**Runtime stage checklist**:\n- [ ] Minimal base image (alpine\u002Fslim\u002Fdistroless\u002Fscratch as appropriate)\n- [ ] Non-root user created (UID 10001+)\n- [ ] Only runtime artifacts copied from builder\n- [ ] No source code, tests, build tools, or dev dependencies\n- [ ] Proper ownership set\n- [ ] USER directive before CMD\n- [ ] EXPOSE only if port was verified in analysis\n- [ ] CMD in exec form (JSON array)\n\n#### System Package Installation Pattern\n\nWhen system packages are required, use the package manager appropriate for your base image. The principle is always the same: **install only what's needed and clean the cache in the same layer**.\n\nCommon examples (adapt to your base image's package manager):\n\n```dockerfile\n# apt-get (Debian, Ubuntu)\nRUN apt-get update && \\\n    apt-get install -y --no-install-recommends \\\n        package1 \\\n        package2 && \\\n    rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*\n\n# apk (Alpine)\nRUN apk add --no-cache \\\n        package1 \\\n        package2\n\n# yum\u002Fdnf (RHEL, Fedora, CentOS)\nRUN yum install -y \\\n        package1 \\\n        package2 && \\\n    yum clean all && \\\n    rm -rf \u002Fvar\u002Fcache\u002Fyum\n```\n\n**Package installation checklist**:\n- [ ] Used the correct package manager for the base image\n- [ ] Used flags to skip optional\u002Frecommended packages where available\n- [ ] Packages sorted alphabetically for maintainability\n- [ ] Cache cleaned in same RUN command\n- [ ] Only packages actually required by the application\n\n### Step 3: Create or Improve .dockerignore\n\n**If no existing .dockerignore** → Generate a minimal one based on the Dockerfile.\n\n**If existing .dockerignore found** → Review it against the Dockerfile's COPY commands:\n1. Remove redundant exclusions (directories not copied by Dockerfile anyway)\n2. Add missing security exclusions (secrets inside copied directories)\n3. Keep it minimal (~10-15 lines)\n\n**Generate a MINIMAL .dockerignore file based on the Dockerfile.**\n\nSince the Dockerfile uses **explicit COPY commands** (not `COPY . .`), .dockerignore serves a limited purpose:\n\n1. **Security** - Exclude secret patterns that could exist INSIDE directories being copied\n2. **Performance** - Exclude large directories that slow down build context transfer\n\n#### Process\n\n1. Review your Dockerfile's COPY commands - what directories does it copy?\n2. Identify security risks inside those directories (secret files that could accidentally exist)\n3. Identify large directories in the project (>1MB) that slow context transfer\n4. Exclude ONLY those items\n\n#### What NOT To Exclude\n\n**DO NOT exclude directories that aren't copied by your Dockerfile!**\n\nIf your Dockerfile doesn't copy a directory, excluding it in .dockerignore is pointless redundancy.\n\n#### Target Size\n\n**~10-15 lines maximum.** If your .dockerignore exceeds 20 lines, you're likely adding unnecessary exclusions.\n\n### Step 4: Build, Test, and Iterate\n\n**Purpose**: Verify the Dockerfile works before presenting to user. A Dockerfile isn't done until it's validated.\n\n#### 4.1 Build\n\nBuild the image to verify the Dockerfile syntax and instructions are correct:\n\n```bash\ndocker build -t [project-name]-validation .\n```\n\n- If build succeeds → proceed to run\n- If build fails → analyze the error, fix Dockerfile, retry\n\n#### 4.2 Run\n\nStart a container to verify the application runs:\n\n```bash\ndocker run -d --name [project-name]-test [project-name]-validation\nsleep 5  # Allow startup time\n```\n\nCheck container state:\n\n```bash\ndocker inspect --format='{{.State.Status}}' [project-name]-test\ndocker inspect --format='{{.State.ExitCode}}' [project-name]-test\n```\n\n**Expected behavior depends on application type** (determined in Step 1):\n- **Services** (web servers, APIs, workers): Container should still be running\n- **CLI tools \u002F one-shot commands**: Container should have exited with code 0\n\nIf container crashed or exited unexpectedly → proceed to log analysis to understand why.\n\n#### 4.3 Log Analysis\n\nCapture and analyze container logs:\n\n```bash\ndocker logs [project-name]-test 2>&1\n```\n\n**Analyze logs using your knowledge of the project from Step 1.** You know:\n- What language and framework this is\n- What the application is supposed to do\n- What dependencies it requires\n- What a successful startup looks like for this type of application\n\nUse this context to determine if the logs indicate:\n- The application started correctly, OR\n- Something is wrong (errors, crashes, missing dependencies, permission issues, etc.)\n\nIf logs indicate a problem → identify root cause, fix Dockerfile or .dockerignore, retry.\n\n#### 4.4 Linting (if available)\n\nIf `hadolint` is installed, run it to catch Dockerfile best practice issues:\n\n```bash\nhadolint Dockerfile\n```\n\n- If hadolint is not installed → skip this check\n- If hadolint reports issues → evaluate each issue, fix if appropriate, retry\n- Some hadolint warnings may be intentional (use judgment based on project context)\n\n#### 4.5 Security Scan (if available)\n\nIf `trivy` is installed, scan the built image for vulnerabilities:\n\n```bash\ntrivy image --severity HIGH,CRITICAL [project-name]-validation\n```\n\n- If trivy is not installed → skip this check\n- If trivy reports HIGH\u002FCRITICAL vulnerabilities in the base image → consider if a different base image version or variant would help\n- If vulnerabilities are in application dependencies → note them for the user but don't block (dependency updates are outside Dockerfile scope)\n\n#### 4.6 Iterate\n\nIf any validation step fails:\n\n1. **Analyze** the specific error message or behavior\n2. **Identify root cause** - common issues include:\n   - Missing file → incorrect COPY command or overly aggressive .dockerignore\n   - Missing dependency → system package not installed\n   - Permission denied → ownership or USER directive issue\n   - Module not found → build step incomplete or wrong files copied\n   - Hadolint warning → Dockerfile best practice issue\n3. **Fix** the appropriate file (Dockerfile or .dockerignore)\n4. **Retry** from step 4.1\n\n**Maximum 5 iterations.** If still failing after 5 attempts:\n- Stop and present current state to user\n- Explain what's failing and what fixes were attempted\n- Ask for guidance\n\n#### 4.7 Cleanup\n\n**Always clean up after validation**, whether successful or not:\n\n```bash\ndocker stop [project-name]-test 2>\u002Fdev\u002Fnull || true\ndocker rm [project-name]-test 2>\u002Fdev\u002Fnull || true\ndocker rmi [project-name]-validation 2>\u002Fdev\u002Fnull || true\n```\n\nOnly proceed to present the Dockerfile to user after:\n- All validation steps pass, AND\n- Cleanup is complete\n\n---\n\n## Output Format\n\n### For New Dockerfiles (no existing file)\n\n**Present both files to the user:**\n\n1. **Dockerfile** with clear comments explaining each section\n2. **.dockerignore** with organized sections\n\n**After generating, provide:**\n- Brief explanation of design choices (base images, build stages, security measures)\n- Build command: `docker build -t [project-name] .`\n- Run command: `docker run -p [port]:[port] [project-name]`\n- Image size expectations\n\n### For Improved Dockerfiles (existing file found)\n\n**Present the improved files with a summary of changes:**\n\n1. **Dockerfile** - the improved version\n2. **Changes made** - brief list of what was changed and why:\n   - Security fixes (e.g., \"Added non-root user - was running as root\")\n   - Optimization improvements (e.g., \"Added multi-stage build to reduce image size\")\n   - Best practice updates (e.g., \"Changed CMD to exec form for signal handling\")\n3. **Preserved** - note any intentional customizations that were kept\n4. **.dockerignore** - improved version if changes were needed\n\n### For Both Cases\n\n**Recommended next steps** (the Dockerfile has already been validated):\n- Integrate into CI\u002FCD pipeline\n- Commit to version control\n\n---\n\n## Success Criteria\n\n### Dockerfile Checklist\n\n- [ ] Builds successfully without errors\n- [ ] Uses multi-stage build (builder → runtime)\n- [ ] Runs as non-root user (UID 10001+)\n- [ ] Uses pinned version tags (no `:latest`)\n- [ ] Uses minimal base images (alpine\u002Fslim\u002Fdistroless)\n- [ ] Copies dependency manifests before source (layer caching)\n- [ ] Uses explicit COPY (no `COPY . .`)\n- [ ] Combines RUN commands with `&&`\n- [ ] Cleans package manager caches in same layer\n- [ ] Uses `--no-install-recommends` (if apt-get used)\n- [ ] Uses exec form for CMD (`[\"executable\", \"arg\"]`)\n- [ ] No debugging tools unless required\n- [ ] No secrets or credentials embedded\n\n### .dockerignore Checklist\n\n- [ ] Minimal size (~10-15 lines)\n- [ ] Excludes secrets inside copied directories\n- [ ] Excludes large unnecessary directories\n- [ ] Does NOT exclude directories not copied by Dockerfile\n\n### Validation Checklist (Step 4)\n\n- [ ] Image builds successfully\n- [ ] Container starts without crashing\n- [ ] Logs show no errors indicating application failure\n- [ ] Hadolint passes (if installed)\n- [ ] Trivy shows no critical base image vulnerabilities (if installed)\n- [ ] Test container and image cleaned up\n\n**Do not present Dockerfile to user until all validation checks pass.**\n\n---\n\n## Example Workflows\n\n### New Dockerfile (no existing file)\n\n1. **Check**: \"No existing Dockerfile found. Will generate new one.\"\n2. **Explore**: \"Let me find the dependency manifest... found `\u003Cmanifest-file>`. Reading it to understand the ecosystem.\"\n3. **Identify**: \"This is a `\u003Clanguage>` project using `\u003Cframework\u002Ftool>`. The manifest indicates version `\u003CX>`.\"\n4. **Trace**: \"The entry point is `\u003Cfile>`. Following imports to understand runtime needs.\"\n5. **Structure**: \"Multi-stage build: builder stage needs `\u003Cbuild-tools>`, runtime stage needs only `\u003Cruntime-artifacts>`.\"\n6. **Dependencies**: \"Searching for external binary usage... found `\u003Cbinary>`. This needs to be in the runtime image.\"\n7. **Generate**: \"Create Dockerfile and .dockerignore. Check against best practices checklists.\"\n8. **Build & Test**: \"Building image... Running container... Checking logs...\"\n9. **Iterate** (if needed): \"Build failed due to missing package. Adding to Dockerfile and retrying...\"\n10. **Cleanup & Present**: \"Validation passed. Removing test artifacts. Here's your Dockerfile.\"\n\n### Improving Existing Dockerfile\n\n1. **Check**: \"Found existing Dockerfile. Reading it to analyze...\"\n2. **Analyze project**: Same exploration as above to understand what the Dockerfile should do.\n3. **Evaluate**: \"Checking existing Dockerfile against best practices checklists...\"\n   - \"❌ Running as root - no USER directive\"\n   - \"❌ Using :latest tag instead of pinned version\"\n   - \"✅ Multi-stage build already in place\"\n   - \"✅ Dependency manifests copied first\"\n4. **Preserve**: \"Keeping custom ENV variables and the specific port configuration - these appear intentional.\"\n5. **Improve**: \"Adding non-root user, pinning image version to match project requirements.\"\n6. **Build & Test**: \"Building improved image... Running container... Checking logs...\"\n7. **Iterate** (if needed): \"Container crashed - logs show permission error. Fixing ownership and retrying...\"\n8. **Cleanup & Present**: \"Validation passed. Removing test artifacts. Here are the improvements.\"\n\n**Key mindset**: Investigate the actual project rather than matching against templates. Every project is unique. Don't present until validated.\n\n",{"name":5,"description":7,"user-invocable":34},true,"main","6faa9f452f568fc9aa9b1c17ee728de11b760cb7",".claude\u002Fskills\u002Fdot-ai-generate-dockerfile",1,"https:\u002F\u002Fgithub.com\u002Fvfarcic\u002Fdot-ai-headlamp","https:\u002F\u002Fgithub.com\u002Fvfarcic","https:\u002F\u002Fyoutube.com\u002Fc\u002Fdevopstoolkit","Developer Advocate @Upbound","2026-06-19 10:10:13",{"source":8,"skillName":5,"commands":45,"prompt":55,"zipAvailable":34},[46,49,52],{"tool":47,"command":48},"npx","npx skills add vfarcic\u002Fdot-ai-headlamp --skill dot-ai-generate-dockerfile",{"tool":50,"command":51},"bunx","bunx skills add vfarcic\u002Fdot-ai-headlamp --skill dot-ai-generate-dockerfile",{"tool":53,"command":54},"pnpm","pnpm dlx skills add vfarcic\u002Fdot-ai-headlamp --skill dot-ai-generate-dockerfile","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fvfarcic\u002Fdot-ai-headlamp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdot-ai-generate-dockerfile\u002FSKILL.md",[],[58,82,100,121,135,145],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":29},"01M6CX45JYT898C3M792AXA5HS","dot-ai","Kubernetes cluster operations via dot-ai CLI - natural language cluster queries, AI-powered deployment recommendations, issue troubleshooting and remediation, Day 2 operations (scale, update, rollback, delete), resources, namespaces, events, logs, organizational knowledge base (ingest, search, query), organizational patterns\u002Fpolicies\u002Fcapabilities management, project scaffolding and repo audit, and session history and visualization. Run `dot-ai --help` for commands.","https:\u002F\u002Fgithub.com\u002Fvfarcic\u002Fdot-ai-headlamp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdot-ai\u002FSKILL.md",[],[21,23,65,66,67,68,69,70,71,72,73,74,27,75,76,77,78,79,80,81],"visualization","delete","repo","deployment","kubernetes","capabilities","search","logs","knowledge","history","session","ingest","queries","natural language","query","scaffolding","knowledge base",{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":29},"01M6CX42HR85829TGFQ95E7283","dot-ai-write-docs","Write documentation with real, validated examples. Executes commands through the user to capture actual output. Use for any new documentation or major doc updates.","https:\u002F\u002Fgithub.com\u002Fvfarcic\u002Fdot-ai-headlamp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdot-ai-write-docs\u002FSKILL.md",[],[21,89,23,90,91,92,93,94,95,96,97,98,99],"docs","write","dot ai write docs","write documentation","commands","use","documentation","examples","doc","capture","user",{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":111,"publishedAt":29},"01M6CX4023QEXSVV5C22GG68XW","dot-ai-worktree-prd","Create a git worktree for PRD work with a descriptive branch name. Infers PRD from context or asks user.","https:\u002F\u002Fgithub.com\u002Fvfarcic\u002Fdot-ai-headlamp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdot-ai-worktree-prd\u002FSKILL.md",[106],{"categoryNo":107,"categoryName":108,"taxonomyType":109,"taxonomyTypeDesc":110},"01JBSEEDCAT000000000000031","产品经理","PROFESSION","适用职业",[112,113,21,114,23,115,116,117,118,119,120,99],"prd","worktree","dot ai worktree prd","create","git","git worktree","work","branch","context",{"skillNo":122,"name":123,"nameZh":6,"description":124,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":125,"categories":126,"keywords":127,"publishedAt":29},"01M6CX3YETQD0A9BPXXQABX0MW","dot-ai-version","Get comprehensive system health and diagnostics","https:\u002F\u002Fgithub.com\u002Fvfarcic\u002Fdot-ai-headlamp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdot-ai-version\u002FSKILL.md",[],[23,128,21,129,130,131,132,133,134],"dot ai version","version","diagnostics","health","system","system health","get",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":29},"01M6CX3X07RSJTPNSFEQRX9ACY","dot-ai-users","Manage users (create, list, delete)","https:\u002F\u002Fgithub.com\u002Fvfarcic\u002Fdot-ai-headlamp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdot-ai-users\u002FSKILL.md",[],[23,142,21,115,66,143,144],"dot ai users","list","manage",{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"publishedAt":29},"01M6CX3T6YE6PVSBJGP2WSXM9J","dot-ai-tag-release","Create a release tag based on accumulated changelog fragments. Run when ready to cut a release.","https:\u002F\u002Fgithub.com\u002Fvfarcic\u002Fdot-ai-headlamp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdot-ai-tag-release\u002FSKILL.md",[],[23,152,21,153,115,154,155,26],"dot ai tag release","release","run","changelog"]