setup-compose-stack
About
This Claude skill helps developers configure Docker Compose stacks for common multi-service application patterns like web apps with databases, caches, and workers. It covers essential orchestration features including named volumes, networks, health checks, and environment management. Use it when setting up reproducible development environments or production-like service orchestration across teams.
Quick Install
Claude Code
Recommendednpx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/setup-compose-stackCopy and paste this command in Claude Code to install this skill
Documentation
設 Compose 棧
配 Docker Compose 為多服應棧含庫、緩、工。
用
- 行網應含庫/緩→用
- 設多服開境→用
- 排背工於 API 旁→用
- 跨組需可重多服境→用
入
- 必:應服(語、口、入點)
- 必:所需輔服(庫、緩、隊等)
- 可:開 vs 產配
- 可:自服既 Dockerfile
行
一:定核棧
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
DATABASE_URL: postgres://appuser:apppass@postgres:5432/appdb
REDIS_URL: redis://redis:6379
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_started
restart: unless-stopped
postgres:
image: postgres:16
environment:
POSTGRES_DB: appdb
POSTGRES_USER: appuser
POSTGRES_PASSWORD: apppass
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U appuser -d appdb"]
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redisdata:/data
volumes:
pgdata:
redisdata:
得:docker compose up 啟諸服、應待健庫。
二:加健察
健察使 depends_on 能用 condition: service_healthy:
services:
postgres:
healthcheck:
test: ["CMD-SHELL", "pg_isready -U appuser -d appdb"]
interval: 5s
timeout: 5s
retries: 5
redis:
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
app:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s
三:配網
services:
app:
networks:
- frontend
- backend
postgres:
networks:
- backend
nginx:
networks:
- frontend
ports:
- "80:80"
networks:
frontend:
driver: bridge
backend:
driver: bridge
此隔庫於直外達、應跨兩網。
四:管環變
建 .env(git 忽):
POSTGRES_PASSWORD=secure_password_here
APP_SECRET=your_secret_key
於 compose 用:
services:
postgres:
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
app:
env_file:
- .env
建 .env.example(提至 git):
POSTGRES_PASSWORD=changeme
APP_SECRET=changeme
五:加工服
services:
worker:
build:
context: .
dockerfile: Dockerfile
command: ["node", "src/worker.js"]
environment:
DATABASE_URL: postgres://appuser:apppass@postgres:5432/appdb
REDIS_URL: redis://redis:6379
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_started
restart: unless-stopped
deploy:
replicas: 2
六:用組為可選服
services:
app:
build: .
mailhog:
image: mailhog/mailhog
ports:
- "8025:8025"
profiles:
- dev
adminer:
image: adminer
ports:
- "8080:8080"
profiles:
- dev
# Start core services only
docker compose up
# Start with dev tools
docker compose --profile dev up
七:建覆為開
docker-compose.override.yml 自合:
services:
app:
build:
target: dev
volumes:
- .:/app
- /app/node_modules
environment:
NODE_ENV: development
DEBUG: "app:*"
command: ["npm", "run", "dev"]
八:建行
docker compose build
docker compose up -d
docker compose logs -f app
docker compose ps
docker compose down
docker compose down -v
得:諸服啟、健察過、應連庫與緩。
敗:察 docker compose logs <service>。常題:口衝、缺環變、健察超時。
驗
-
docker compose up啟諸服無誤 - 庫與緩健察過
- 應連諸依服
- 名卷跨啟保資
-
.envgit 忽、.env.example提 -
docker compose down潔停諸 - 組分開工於產服
忌
- 無健察:
depends_on無condition: service_healthy僅待容啟、非備 - 硬碼密於 compose:用
.env或 Docker secrets。永勿提密 - 卷掛覆:掛
.:/app覆像內node_modules。用匿卷:/app/node_modules - 口衝:察
docker compose ps與lsof -i :<port>衝 version:鍵:Compose V2 忽version:。今設略之- WSL 徑問題:自 WSL 掛 Windows 目用
/mnt/c/...
參
setup-docker-composecreate-dockerfilecreate-multistage-dockerfileconfigure-nginx
GitHub Repository
Related Skills
content-collections
MetaThis skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.
polymarket
MetaThis skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.
creating-opencode-plugins
MetaThis skill helps developers create OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It provides the plugin structure, event API specifications, and implementation patterns for JavaScript/TypeScript modules. Use it when you need to intercept, monitor, or extend the OpenCode AI assistant's lifecycle with custom event-driven logic.
sglang
MetaSGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.
