docker-compose.yml•2.69 kB
version: '3.8'
services:
# 生产环境配置
mcp-server-prod:
build: .
container_name: awesome-mcp-server-prod
ports:
- "8000:8000"
environment:
- ENVIRONMENT=production
- HOST=0.0.0.0
- PORT=8000
- TRANSPORT=streamable-http
- LOG_LEVEL=info
- UVICORN_WORKERS=4
- UVICORN_MAX_REQUESTS=1000
- UVICORN_MAX_REQUESTS_JITTER=100
- UVICORN_KEEPALIVE=2
volumes:
- ./workspace:/app/workspace
- ./logs:/app/logs
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
deploy:
resources:
limits:
cpus: '2.0'
memory: 1G
reservations:
cpus: '0.5'
memory: 256M
# 开发环境配置
mcp-server-dev:
build: .
container_name: awesome-mcp-server-dev
ports:
- "8001:8000"
environment:
- ENVIRONMENT=development
- HOST=0.0.0.0
- PORT=8000
- TRANSPORT=streamable-http
- LOG_LEVEL=debug
volumes:
- ./server:/app/server
- ./workspace:/app/workspace
- ./logs:/app/logs
restart: unless-stopped
profiles:
- dev
# 负载均衡配置 (使用 nginx)
nginx:
image: nginx:alpine
container_name: mcp-nginx-lb
ports:
- "80:80"
- "443:443"
volumes:
- ./deploy/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./deploy/nginx/ssl:/etc/nginx/ssl:ro
depends_on:
- mcp-server-prod
restart: unless-stopped
profiles:
- lb
# 监控配置 (Prometheus + Grafana)
prometheus:
image: prom/prometheus:latest
container_name: mcp-prometheus
ports:
- "9090:9090"
volumes:
- ./deploy/monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
restart: unless-stopped
profiles:
- monitoring
grafana:
image: grafana/grafana:latest
container_name: mcp-grafana
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin123
volumes:
- grafana_data:/var/lib/grafana
- ./deploy/monitoring/grafana:/etc/grafana/provisioning
depends_on:
- prometheus
restart: unless-stopped
profiles:
- monitoring
volumes:
prometheus_data:
grafana_data:
networks:
default:
name: mcp-network