docker-compose.prod.yml•3.6 kB
version: '3.8'
services:
redis:
image: redis:alpine
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
volumes:
- redis_data:/data
- ./redis.conf:/usr/local/etc/redis/redis.conf:ro
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 10s
timeout: 5s
retries: 3
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
networks:
- mcp_network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
mcp_server:
build:
context: ..
dockerfile: docker/Dockerfile.template
args:
NODE_ENV: production
environment:
- NODE_ENV=production
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
deploy:
replicas: 2
update_config:
parallelism: 1
delay: 10s
restart_policy:
condition: on-failure
max_attempts: 3
resources:
limits:
cpus: '1.0'
memory: 1G
depends_on:
redis:
condition: service_healthy
networks:
- mcp_network
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
logging:
driver: "json-file"
options:
max-size: "20m"
max-file: "5"
prometheus:
image: prom/prometheus:latest
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
networks:
- mcp_network
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
grafana:
image: grafana/grafana:latest
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
- GF_USERS_ALLOW_SIGN_UP=false
networks:
- mcp_network
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
nginx:
image: nginx:alpine
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./ssl:/etc/nginx/ssl:ro
ports:
- "443:443"
depends_on:
- mcp_server
networks:
- mcp_network
deploy:
resources:
limits:
cpus: '0.25'
memory: 256M
healthcheck:
test: ["CMD", "nginx", "-t"]
interval: 30s
timeout: 10s
retries: 3
backup:
image: alpine
volumes:
- redis_data:/data:ro
- ./backups:/backups
command: |
sh -c 'while true; do
timestamp=$$(date +%Y%m%d_%H%M%S);
tar czf /backups/redis_$$timestamp.tar.gz /data;
find /backups -type f -mtime +7 -delete;
sleep 86400;
done'
deploy:
resources:
limits:
cpus: '0.10'
memory: 128M
volumes:
redis_data:
driver: local
prometheus_data:
driver: local
grafana_data:
driver: local
networks:
mcp_network:
driver: overlay
name: mcp_network_prod
driver_opts:
encrypted: "true"
ipam:
driver: default
config:
- subnet: "172.20.0.0/16"