Skill

docker_compose

Generates multi-stage Dockerfiles and docker-compose.yml configurations, adds services like Postgres/Redis/Celery/Nginx, and checks for Docker anti-patterns. Use when asked to "dockerize", "create dockerfile", "docker compose", "add docker", "add redis", "add postgres", "docker init", "optimize docker", or "container setup".

From docker-compose
Install
1
Run in your terminal
$
npx claudepluginhub shouenlee/ghcp-dev-plugin --plugin docker-compose
Tool Access

This skill uses the workspace's default tool permissions.

Skill Content

Docker Compose

Generate production-ready Dockerfiles and docker-compose configurations, add common services, and audit existing Docker setups for anti-patterns.

When to Use

  • You need to containerize an existing project with a Dockerfile and docker-compose.yml
  • You want to add a service (database, cache, worker, proxy) to an existing compose setup
  • You want to audit your Dockerfile and compose configuration for best practices

Prerequisites

  • Docker and docker-compose installed locally (for validation and testing)
  • A project with an identifiable language and framework (Python, Node.js, Go)

Workflow

This skill supports three subcommands: /docker init, /docker add <service>, and /docker optimize.


/docker init -- Generate Dockerfile + compose

  1. Detect project type (Python/Node/Go) and framework:

    # Python detection
    ls requirements.txt pyproject.toml Pipfile setup.py 2>/dev/null
    
    # Node detection
    ls package.json 2>/dev/null
    
    # Go detection
    ls go.mod 2>/dev/null
    
  2. Detect package manager and dependency files:

    • Python: pip (requirements.txt), poetry (pyproject.toml), pipenv (Pipfile)
    • Node: npm (package-lock.json), yarn (yarn.lock), pnpm (pnpm-lock.yaml)
    • Go: go modules (go.mod)
  3. Generate a multi-stage Dockerfile:

    • Build stage: install dependencies first (for layer caching), then copy source
    • Production stage: minimal base image, create non-root user, copy artifacts from build
    # Example: Python multi-stage
    FROM python:3.12-slim AS builder
    WORKDIR /app
    COPY requirements.txt .
    RUN pip install --no-cache-dir -r requirements.txt
    
    FROM python:3.12-slim
    RUN useradd --create-home appuser
    WORKDIR /app
    COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
    COPY . .
    USER appuser
    EXPOSE 8000
    CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
    
  4. Generate docker-compose.yml with:

    • App service with a health check
    • Volume mounts for development (source code, exclude node_modules/venv)
    • Environment variables loaded from .env
    version: "3.9"
    services:
      app:
        build: .
        ports:
          - "8000:8000"
        volumes:
          - .:/app
        env_file:
          - .env
        healthcheck:
          test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
          interval: 30s
          timeout: 10s
          retries: 3
    
  5. Generate .dockerignore if not already present, including common exclusions:

    .git
    .venv
    __pycache__
    node_modules
    .env
    *.pyc
    .mypy_cache
    .pytest_cache
    
  6. Present all generated files for review before writing to disk.


/docker add <service> -- Add a service

  1. Read the existing docker-compose.yml to understand current services, networks, and volumes.

  2. Add the appropriate service block based on the requested service name:

    • postgres: PostgreSQL with health check, persistent volume, and environment variables

      postgres:
        image: postgres:16-alpine
        environment:
          POSTGRES_DB: app_db
          POSTGRES_USER: app_user
          POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
        volumes:
          - postgres_data:/var/lib/postgresql/data
        healthcheck:
          test: ["CMD-SHELL", "pg_isready -U app_user -d app_db"]
          interval: 10s
          timeout: 5s
          retries: 5
      
    • redis: Redis with persistence and health check

      redis:
        image: redis:7-alpine
        command: redis-server --appendonly yes
        volumes:
          - redis_data:/data
        healthcheck:
          test: ["CMD", "redis-cli", "ping"]
          interval: 10s
          timeout: 5s
          retries: 5
      
    • celery: Celery worker using the same image as the app service, depends_on app

      celery:
        build: .
        command: celery -A app worker --loglevel=info
        depends_on:
          - app
          - redis
        env_file:
          - .env
      
    • celery-beat: Celery beat scheduler

      celery-beat:
        build: .
        command: celery -A app beat --loglevel=info
        depends_on:
          - celery
        env_file:
          - .env
      
    • nginx: Nginx reverse proxy with configuration volume

      nginx:
        image: nginx:alpine
        ports:
          - "80:80"
        volumes:
          - ./nginx.conf:/etc/nginx/conf.d/default.conf
        depends_on:
          - app
      
    • mailhog: Development email catcher

      mailhog:
        image: mailhog/mailhog
        ports:
          - "1025:1025"
          - "8025:8025"
      
  3. Add necessary networks, volumes, and depends_on relationships to wire the new service into the existing compose graph.

  4. Update the app service environment to reference the new service (e.g., add DATABASE_URL, REDIS_URL, or CELERY_BROKER_URL).

  5. Present the updated compose file for review.


/docker optimize -- Check for anti-patterns

  1. Read the Dockerfile and docker-compose.yml from the project root.

  2. Check for common issues:

    CheckSeverityWhat to look for
    Running as rootHighNo USER directive in Dockerfile
    No .dockerignoreMediumMissing file or missing key entries (.git, node_modules, .env)
    COPY before depsMediumSource copied before dependency install, breaking layer cache
    Using latest tagMediumBase image uses :latest instead of a pinned version
    No health checksMediumNo HEALTHCHECK in Dockerfile or healthcheck in compose
    Bloated final imageLowBuild tools (gcc, make) present in production stage
    Secrets in env/argsHighPasswords or tokens in ENV or ARG directives
    No multi-stage buildLowSingle FROM with both build and runtime dependencies
  3. Present findings with severity level and a concrete fix suggestion for each issue:

    [HIGH] Running as root
      -> Add USER directive: RUN useradd -m appuser && USER appuser
    
    [MEDIUM] Using latest tag for base image
      -> Pin version: python:3.12-slim instead of python:latest
    
  4. Offer to apply fixes automatically where possible (adding USER, reordering COPY, pinning tags).

Troubleshooting

ProblemCauseSolution
Project type not detectedNo recognizable dependency filesManually specify the language and framework
Conflicting portsAnother service already uses the requested portChange the host port mapping in docker-compose.yml
Service name conflictsA service with the same name already exists in composeChoose a different name or update the existing service
Health check failsApplication does not expose a health endpointAdd a /health endpoint to your application or adjust the health check command
Permission denied errorsNon-root user cannot access mounted volumesEnsure volume permissions match the container user UID
Similar Skills
cache-components

Expert guidance for Next.js Cache Components and Partial Prerendering (PPR). **PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their next.config.ts/next.config.js. When this config is detected, proactively apply Cache Components patterns and best practices to all React Server Component implementations. **DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in next.config. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions. **USE CASES**: Implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, debugging cache issues, and reviewing Cache Component implementations.

138.5k
Stats
Parent Repo Stars0
Parent Repo Forks0
Last CommitMar 5, 2026