Docker

From tinh2/skills-hub-registry · View interactive version

Docker is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Detect project stack and generate production-ready multi-stage Dockerfiles with compose services, .dockerignore, non-root users, health checks, layer caching, and optional dev hot-reload profiles

How to use this skill

Skill file

You are in AUTONOMOUS MODE. Do NOT ask questions. Do NOT pause for confirmation.

Execute every phase below in sequence, making decisions based on what you find.

============================================================

PHASE 0 — INPUT

============================================================

$ARGUMENTS may contain:

If no arguments, generate both Dockerfile and docker-compose.yml if the project has dependencies (database, cache, etc.).

============================================================

PHASE 1 — STACK DETECTION

============================================================

Detect the application stack by reading manifest files:

Node.js:

Python:

Go:

Rust:

Java:

Ruby:

Also detect dependencies that need compose services:

============================================================

PHASE 2 — GENERATE DOCKERFILE

============================================================

Create a multi-stage Dockerfile following these principles:

Stage 1 — Dependencies (deps or builder):

Stage 2 — Build (if applicable):

Stage 3 — Production:

Security hardening (always apply):

Health check (always include):

Labels (OCI standard):

LABEL org.opencontainers.image.source="https://github.com/OWNER/REPO"
LABEL org.opencontainers.image.description="Description"

Environment:

============================================================

PHASE 3 — GENERATE .dockerignore

============================================================

Create .dockerignore to minimize build context. Always exclude:

Adjust patterns based on detected stack.

============================================================

PHASE 4 — GENERATE DOCKER COMPOSE

============================================================

Create docker-compose.yml if the application has external dependencies or --compose is set.

Structure requirements:

Database services: Include proper health checks:

Cache services: Include memory limits and eviction policy configuration.

Development profile (if --dev):

Create a docker-compose.dev.yml override with:

============================================================

PHASE 5 — VALIDATION

============================================================

After generating files, verify:

  1. Layer ordering — dependency install comes before source copy
  2. No secrets — no hardcoded passwords, API keys, or tokens in Dockerfile or compose
  3. Port consistency — EXPOSE matches the app's actual listen port
  4. Health check — endpoint referenced in HEALTHCHECK actually exists (or note to create it)
  5. Base image tags — all pinned to specific versions, no latest
  6. Non-root user — USER directive is present and set before CMD

============================================================

SELF-HEALING VALIDATION (max 2 iterations)

============================================================

After completing deployment/infrastructure changes, validate:

  1. Verify all generated files are syntactically valid (YAML, JSON, HCL, Dockerfile).
  2. Run validation commands if available (terraform validate, docker build --check, kubectl dry-run).
  3. Verify no secrets, credentials, or sensitive values are hardcoded.
  4. If validation fails, diagnose and fix the specific syntax or config error.
  5. Repeat up to 2 iterations.

IF STILL FAILING after 2 iterations:

============================================================

OUTPUT

============================================================

Print a summary:

## Docker Setup Complete

### Files Created
- Dockerfile — Multi-stage build ({base image}, {final size estimate})
- .dockerignore — {N} patterns to minimize build context
- docker-compose.yml — Services: {list}
- docker-compose.dev.yml — Development overrides (if generated)

### Build Commands
- Production: docker compose up --build -d
- Development: docker compose -f docker-compose.yml -f docker-compose.dev.yml up
- Image only: docker build -t {name}:latest .

### Image Details
- Base: {base image}
- Estimated size: {size estimate}
- User: appuser (non-root, UID 1001)
- Health check: {endpoint}
- Exposed port: {port}

### Services
| Service | Image | Port | Volume |
|---------|-------|------|--------|
| app | built | {port} | -- |
| db | postgres:16 | 5432 | db-data |

============================================================

NEXT STEPS

============================================================

  1. Build and test locally: docker compose up --build
  2. Add a /health endpoint to the application if one does not exist
  3. Configure CI/CD to build and push the Docker image (run deploy/github-actions)
  4. Set real database credentials via environment variables or secrets manager (run deploy/secrets)

============================================================

SELF-EVOLUTION TELEMETRY

============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

Entry format:

### /docker — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}

Only log if the memory directory exists. Skip silently if not found.

Keep entries concise — /evolve will parse these for skill improvement signals.

============================================================

DO NOT

============================================================

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.