Docker compose generator
Skill timwukp/agent-skills-best-practice/skills/skills/docker-compose-generator
35 portable agent skills (Agent Skills spec) for Kiro & Claude Code: Scrum DevSecOps roles, PCI-DSS/MAS TRM compliance, AWS Well-Architected reviews — each with evals and a 4-layer tested methodology
npx -y skills add timwukp/agent-skills-best-practice --skill docker-compose-generatorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 7 stars7 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
Generates multi-stage Dockerfiles and docker-compose configurations optimized for size, security, and development workflow. Covers common stacks including Node.js, Python, Java, and Go. Triggers on: "create Dockerfile", "docker-compose", "containerize", "docker setup".
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
6.1 KB, as published. Nobody here has run it
Docker Compose Generator
Instructions
Step 1: Identify the Stack
Ask:
- What language/runtime? (Node.js, Python, Java, Go, Ruby, .NET)
- What framework? (Express, FastAPI, Spring Boot, Gin, Rails)
- What services are needed? (database, cache, message queue, search)
- Is this for development, production, or both?
- Any existing Dockerfile to improve?
Step 2: Generate Multi-Stage Dockerfile
Use multi-stage builds to minimize image size:
Node.js example:
# Stage 1: Dependencies
FROM node:20-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --only=production
# Stage 2: Build
FROM node:20-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
# Stage 3: Production
FROM node:20-alpine AS production
RUN addgroup -g 1001 -S appgroup && \
adduser -S appuser -u 1001 -G appgroup
WORKDIR /app
COPY --from=deps --chown=appuser:appgroup /app/node_modules ./node_modules
COPY --from=build --chown=appuser:appgroup /app/dist ./dist
COPY --from=build --chown=appuser:appgroup /app/package.json ./
USER appuser
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
CMD ["node", "dist/index.js"]
Python example:
FROM python:3.12-slim AS base
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
FROM base AS deps
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
FROM base AS production
RUN useradd --create-home --shell /bin/bash appuser
WORKDIR /app
COPY --from=deps /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=deps /usr/local/bin /usr/local/bin
COPY --chown=appuser:appuser . .
USER appuser
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=3s \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
Step 3: Security Best Practices
Apply these rules to every Dockerfile:
- Non-root user - always add a user and switch with
USER - Minimal base images - prefer
-alpineor-slimvariants - Pin versions - use exact tags, never
latest - No secrets in image - use build args or runtime env vars
- Read-only filesystem - set
read_only: truein compose where possible - Drop capabilities - add
cap_drop: [ALL]in compose - Health checks - always include HEALTHCHECK instruction
- Scan for vulnerabilities - add
docker scout cvesto CI
Step 4: Generate docker-compose.yml
Create a compose file for the development environment:
version: "3.8"
services:
app:
build:
context: .
dockerfile: Dockerfile
target: development
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
environment:
- NODE_ENV=development
- DATABASE_URL=postgres://postgres:postgres@db:5432/appdb
- REDIS_URL=redis://cache:6379
depends_on:
db:
condition: service_healthy
cache:
condition: service_started
restart: unless-stopped
db:
image: postgres:16-alpine
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: appdb
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 3s
retries: 5
cache:
image: redis:7-alpine
ports:
- "6379:6379"
command: redis-server --maxmemory 128mb --maxmemory-policy allkeys-lru
volumes:
pgdata:
Step 5: Production Compose Overlay
For production, provide a docker-compose.prod.yml overlay:
version: "3.8"
services:
app:
build:
target: production
volumes: []
environment:
- NODE_ENV=production
deploy:
replicas: 2
resources:
limits:
cpus: "1.0"
memory: 512M
restart_policy:
condition: on-failure
max_attempts: 3
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
db:
environment:
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
secrets:
- db_password
secrets:
db_password:
external: true
Usage: docker compose -f docker-compose.yml -f docker-compose.prod.yml up
Step 6: Common Service Snippets
Provide additional services as requested:
- RabbitMQ:
rabbitmq:3-management-alpinewith management UI on 15672 - MongoDB:
mongo:7with init scripts in/docker-entrypoint-initdb.d/ - Elasticsearch:
elasticsearch:8.xwith single-node discovery - MinIO (S3-compatible):
minio/miniowith console on 9001 - Mailhog (dev email):
mailhog/mailhogwith UI on 8025
Example
User says: "Create a Docker setup for a Python FastAPI app with PostgreSQL and Redis"
Response:
- Multi-stage Dockerfile with slim base, non-root user, health check
- docker-compose.yml with app, postgres, redis services
- Volume mounts for hot reload in development
- Health check dependencies so app waits for DB
- .dockerignore file contents
Guidelines
- Always use multi-stage builds for production images
- Never hardcode passwords in docker-compose files (use environment variables or secrets)
- Include .dockerignore in every project (exclude .git, node_modules, pycache, .env)
- Pin all image versions to specific tags
- Use health checks and depends_on with condition for startup ordering
- Default to Alpine-based images unless the app requires glibc
- Include resource limits in production configurations
- Provide both dev and prod configurations when asked for "Docker setup"