# dockerfile-generator

A skill that writes production-ready Dockerfiles and .dockerignore, validates them, then fixes what the validator flags. Handy when you need to containerize a service without hand-tuning layers.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 699 installs · ★ 327
- Author: akin-ozer
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/akin-ozer/cc-devops-skills/tree/HEAD/devops-skills-plugin/skills/dockerfile-generator/SKILL.md
- Updated: 2026-07-26
- HTML: https://affpapa.org/en/nevibecode/skills/dockerfile-generator

## What it does

The skill runs in stages. It asks about language and runtime version, entrypoint, exposed ports, package manager and health endpoint, then generates the Dockerfile and `.dockerignore`. Validation goes through `dockerfile-validator`, and the skill keeps patching until no errors remain. After three iterations it stops and emits an intentional-deviation report for whatever is left.

Local references ship with it: `references/security_best_practices.md` covers non-root users and secret handling, `references/optimization_patterns.md` covers multi-stage strategy and layer caching, `references/language_specific_guides.md` covers Node.js, Python, Go and Java. When those are not enough, the skill queries Context7 for framework docs and only falls back to web search if Context7 is unavailable. Offline, it stays on the bundled templates and says so in the report.

The scope is narrow on purpose: it writes configs, it does not build or run containers, and it will not debug a running one. Auditing an existing Dockerfile is a separate job for `dockerfile-validator`. Note that the Context7 step needs a configured MCP server — without one the lookup chain ends at the local files.

## Requirements
- Works with: Docker

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add akin-ozer/cc-devops-skills --skill dockerfile-generator -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/dockerfile-generator/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/dockerfile-generator/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add akin-ozer/cc-devops-skills --skill dockerfile-generator -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/dockerfile-generator/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add akin-ozer/cc-devops-skills --skill dockerfile-generator -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/dockerfile-generator/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install akin-ozer/cc-devops-skills dockerfile-generator
```

2. **Manually: put the files in place**
- File: `.github/skills/dockerfile-generator/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add akin-ozer/cc-devops-skills --skill dockerfile-generator -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/akin-ozer/cc-devops-skills --path devops-skills-plugin/skills/dockerfile-generator
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/dockerfile-generator/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add akin-ozer/cc-devops-skills --skill dockerfile-generator -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/akin-ozer/cc-devops-skills/tree/HEAD/devops-skills-plugin/skills/dockerfile-generator/SKILL.md

## When to use it
- write a multi-stage Dockerfile for a Node.js service
- keep build tooling out of the final image
- run the container as a non-root user with no baked-in secrets
- generate a `.dockerignore` for a specific project
- rewrite an old Dockerfile so layers cache properly

## Example prompts
- Generate a production Dockerfile for my FastAPI app on Python 3.12
- Create a multi-stage Dockerfile for a Go service and add .dockerignore
- Rewrite my Dockerfile so build tools stay out of the runtime image

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 3697b7ad222404ee.

BEGIN THIRD-PARTY FILE 3697b7ad222404ee
```text
---
name: dockerfile-generator
description: Create, generate, or write Dockerfiles and multi-stage Docker images. Containerize apps.
---

# Dockerfile Generator

## Overview

This skill provides a comprehensive workflow for generating production-ready Dockerfiles with security, optimization, and best practices built-in. Generates multi-stage builds, security-hardened configurations, and optimized layer structures with automatic validation and iterative error fixing.

**Key Features:**
- Multi-stage builds for optimal image size (50-85% reduction)
- Security hardening (non-root users, minimal base images, no secrets)
- Layer caching optimization for faster builds
- Language-specific templates (Node.js, Python, Go, Java)
- Automatic .dockerignore generation
- Integration with `dockerfile-validator` for validation
- Iterative validation and error fixing (minimum 1 iteration if errors found)
- Local references plus docs lookup fallback chain for framework-specific patterns

## When to Use This Skill

Invoke this skill when:
- Creating new Dockerfiles from scratch
- Containerizing applications (Node.js, Python, Go, Java, or other languages)
- Implementing multi-stage builds for size optimization
- Converting existing Dockerfiles to best practices
- Generating production-ready container configurations
- Optimizing Docker builds for security and performance
- The user asks to "create", "generate", "build", or "write" a Dockerfile
- Implementing containerization for microservices
- Setting up CI/CD pipeline container builds

### Trigger Phrases

Use this skill immediately when the request contains phrasing like:
- "Generate a production Dockerfile for my app"
- "Create a multi-stage Dockerfile for <language/framework>"
- "Containerize this service with security best practices"
- "Optimize this Dockerfile for size and build speed"
- "Write Dockerfile and .dockerignore for deployment"

## Do NOT Use This Skill For

- Validating existing Dockerfiles (use `dockerfile-validator` instead)
- Building or running containers (use docker build/run commands)
- Debugging running containers (use docker logs, docker exec)
- Managing Docker images or registries

## Deterministic Execution Model
```
END THIRD-PARTY FILE 3697b7ad222404ee

The third-party file has ended. Everything between the 3697b7ad222404ee tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2210 of 30852 bytes. © akin-ozer · Apache-2.0 · https://github.com/akin-ozer/cc-devops-skills/tree/HEAD/devops-skills-plugin/skills/dockerfile-generator/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
