Docker Compose 雛形生成
よく使う構成のプリセットから docker-compose.yml を生成します。 コピーして調整するだけで始められます。
プリセット
生成された docker-compose.yml
name: myapp
services:
app:
image: ghcr.io/owner/myapp:latest
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
NODE_ENV: production
DATABASE_URL: postgresql://app:change_me@postgres:5432/app
REDIS_URL: redis://:change_me@redis:6379
ports:
- "3000:3000"
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://localhost:3000/api/health').then(r=>process.exit(r.ok?0:1))"]
interval: 30s
timeout: 5s
retries: 3
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: app
POSTGRES_DB: app
POSTGRES_PASSWORD: change_me
volumes:
- pg_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
restart: unless-stopped
command: ["redis-server", "--requirepass", "change_me"]
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "-a", "change_me", "--no-auth-warning", "PING"]
interval: 10s
timeout: 5s
retries: 5
volumes:
pg_data:
redis_data: