scaffold: Docker infrastructure — Compose, Nginx, NATS, Dockerfile
4-service stack (PostgreSQL 16, NATS JetStream, Rust API, Nginx), multi-stage Rust build with dependency caching, wildcard subdomain routing for public sites, WebSocket support, rate limiting zones. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
89
docker/docker-compose.yml
Normal file
89
docker/docker-compose.yml
Normal file
@@ -0,0 +1,89 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: corrosion-db
|
||||
environment:
|
||||
POSTGRES_DB: corrosion
|
||||
POSTGRES_USER: corrosion
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD:-corrosion_dev}
|
||||
volumes:
|
||||
- pg_data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "5432:5432"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U corrosion"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
nats:
|
||||
image: nats:latest
|
||||
container_name: corrosion-nats
|
||||
command:
|
||||
- "--jetstream"
|
||||
- "--store_dir=/data"
|
||||
- "--config=/etc/nats/nats.conf"
|
||||
volumes:
|
||||
- nats_data:/data
|
||||
- ./nats.conf:/etc/nats/nats.conf:ro
|
||||
ports:
|
||||
- "4222:4222" # Client connections
|
||||
- "8222:8222" # Monitoring
|
||||
- "9222:9222" # WebSocket (frontend real-time)
|
||||
healthcheck:
|
||||
test: ["CMD", "nats-server", "--signal", "ldm"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
|
||||
api:
|
||||
build:
|
||||
context: ../backend
|
||||
dockerfile: ../docker/Dockerfile.api
|
||||
container_name: corrosion-api
|
||||
environment:
|
||||
DATABASE_URL: postgres://corrosion:${DB_PASSWORD:-corrosion_dev}@postgres:5432/corrosion
|
||||
NATS_URL: nats://nats:4222
|
||||
JWT_SECRET: ${JWT_SECRET}
|
||||
ENCRYPTION_KEY: ${ENCRYPTION_KEY}
|
||||
CLOUDFLARE_API_TOKEN: ${CLOUDFLARE_API_TOKEN}
|
||||
CLOUDFLARE_ZONE_ID: ${CLOUDFLARE_ZONE_ID}
|
||||
STEAM_API_KEY: ${STEAM_API_KEY}
|
||||
SMTP_HOST: ${SMTP_HOST:-localhost}
|
||||
SMTP_PORT: ${SMTP_PORT:-587}
|
||||
SMTP_USERNAME: ${SMTP_USERNAME}
|
||||
SMTP_PASSWORD: ${SMTP_PASSWORD}
|
||||
SMTP_FROM: ${SMTP_FROM:-noreply@corrosionmgmt.com}
|
||||
FRONTEND_URL: ${FRONTEND_URL:-https://panel.corrosionmgmt.com}
|
||||
RUST_LOG: corrosion_api=info,tower_http=info
|
||||
volumes:
|
||||
- map_data:/data/maps
|
||||
- backup_data:/data/backups
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
nats:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "3000:3000"
|
||||
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: corrosion-nginx
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ../frontend/dist:/usr/share/nginx/html:ro
|
||||
- map_data:/data/maps:ro
|
||||
depends_on:
|
||||
- api
|
||||
|
||||
volumes:
|
||||
pg_data:
|
||||
nats_data:
|
||||
map_data:
|
||||
backup_data:
|
||||
Reference in New Issue
Block a user