--- name: docker-project-setup description: Containerize any project with Docker and Docker Compose. Use when user says "dockerize", "create Dockerfile", "set up Docker Compose", or "containerize my app". --- Help the user containerize their project with Docker best practices. ## Instructions ### Step 1: Analyze the Project Read the project structure and identify the language/framework, package manager, build requirements, database needs, environment variables, and ports. ### Step 2: Create Dockerfile Use the appropriate template from `assets/` based on the detected stack: - Node.js/Next.js → `assets/Dockerfile.node` - Python → `assets/Dockerfile.python` - Go → `assets/Dockerfile.go` Customize the template for the user's specific project. ### Step 3: Create .dockerignore Use `assets/.dockerignore` as a starting point and adjust for the project. ### Step 4: Create docker-compose.yml Use `assets/docker-compose.yml` as the base template. Add services based on the project's needs (database, cache, etc.). For development, also create a docker-compose.override.yml based on `assets/docker-compose.dev.yml`. ### Step 5: Verify Run `docker compose up --build` and confirm: - App accessible at localhost:PORT - Database connection works - Health check passes See `references/cheatsheet.md` for common Docker commands.
Add to Claude Code
0 addsInstall this Claude Code skill folder.
Name: Docker Project Setup
Save to: ~/.claude/skills/docker-project-setup/
Download: https://claudemcp.io/api/download/docker-project-setup
---
---
name: docker-project-setup
description: Containerize any project with Docker and Docker Compose. Use when user says "dockerize", "create Dockerfile", "set up Docker Compose", or "containerize my app".
---
Help the user containerize their project with Docker best practices.
## Instructions
### Step 1: Analyze the Project
Read the project structure and identify:
- Language/framework (Node.js, Python, Go, Java, etc.)
- Package manager (npm, pnpm, yarn, pip, poetry, go mod)
- Build step required? (TypeScript, Next.js, compiled languages)
- Database needed? (PostgreSQL, MySQL, Redis, MongoDB)
- Environment variables required
- Ports to expose
### Step 2: Create Dockerfile
Generate a multi-stage Dockerfile optimized for the detected stack.
**Node.js/Next.js example:**
```dockerfile
# Stage 1: Dependencies
FROM node:20-alpine AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable pnpm && pnpm install --frozen-lockfile
# Stage 2: Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN corepack enable pnpm && pnpm build
# Stage 3: Production
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs && adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:3000/api/health || exit 1
CMD ["node", "server.js"]
```
**Best practices to always follow:**
- Use specific version tags (node:20-alpine, not node:latest)
- Multi-stage builds to minimize image size
- Non-root user for security
- .dockerignore file to exclude node_modules, .git, .env
- HEALTHCHECK instruction
- Copy package files before source (layer caching)
### Step 3: Create .dockerignore
```
node_modules
.git
.env*
.next
dist
coverage
*.md
.DS_Store
```
### Step 4: Create docker-compose.yml
Generate based on the project's needs:
```yaml
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
env_file: .env
depends_on:
db:
condition: service_healthy
restart: unless-stopped
db:
image: postgres:16-alpine
volumes:
- pgdata:/var/lib/postgresql/data
environment:
POSTGRES_DB: myapp
POSTGRES_USER: myapp
POSTGRES_PASSWORD: ${DB_PASSWORD}
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U myapp"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
volumes:
pgdata:
```
### Step 5: Dev vs Prod Configuration
Create a docker-compose.override.yml for development:
- Volume mounts for hot reload
- Debug ports exposed
- Dev-specific env vars
And a docker-compose.prod.yml for production:
- No volume mounts
- Resource limits (CPU, memory)
- Log configuration
- Restart policies
### Step 6: Common Commands Cheatsheet
Provide the user with:
```bash
# Build and start
docker compose up --build -d
# View logs
docker compose logs -f app
# Shell into container
docker compose exec app sh
# Rebuild single service
docker compose up --build -d app
# Stop everything
docker compose down
# Stop and remove volumes (WARNING: deletes data)
docker compose down -v
```
### Step 7: Verification
- [ ] `docker compose up --build` succeeds
- [ ] App accessible at localhost:PORT
- [ ] Database connection works
- [ ] Health check passes
- [ ] .dockerignore excludes sensitive files
- [ ] Image size is reasonable (check with `docker images`)
Additional files in this skill:
- assets/Dockerfile.node
- assets/Dockerfile.python
- assets/Dockerfile.go
- assets/docker-compose.yml
- assets/docker-compose.dev.yml
- assets/.dockerignore
- references/cheatsheet.mdDownload the zip and extract to your skills directory, or paste into Claude Code.
How to add
Full guide →Click Add, then paste into Claude Code. Claude will save it to the right location for you.
Target: .claude/commands/<name>.md