Upload production/docker-compose.m2.yml
Browse files- production/docker-compose.m2.yml +129 -0
production/docker-compose.m2.yml
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: "3.8"
|
| 2 |
+
|
| 3 |
+
# Optimized for MacBook M2 Pro Max 96GB
|
| 4 |
+
# - MLX local inference runs natively on Metal (host, not in Docker)
|
| 5 |
+
# - Redis, Postgres, API server in lightweight containers
|
| 6 |
+
# - NIM and Cloudflare as cloud fallback
|
| 7 |
+
# - Everything runs natively on Apple Silicon
|
| 8 |
+
|
| 9 |
+
services:
|
| 10 |
+
api:
|
| 11 |
+
build:
|
| 12 |
+
context: .
|
| 13 |
+
dockerfile: Dockerfile.prod
|
| 14 |
+
ports:
|
| 15 |
+
- "8000:8000"
|
| 16 |
+
environment:
|
| 17 |
+
- PORT=8000
|
| 18 |
+
- WORKERS=2
|
| 19 |
+
- REDIS_URL=redis://redis:6379
|
| 20 |
+
- DATABASE_URL=postgresql://ml_intern:ml_intern@postgres:5432/ml_intern
|
| 21 |
+
- MAX_CONCURRENT_REQUESTS=100
|
| 22 |
+
- DEFAULT_RPM_LIMIT=40
|
| 23 |
+
- REQUEST_TIMEOUT=120
|
| 24 |
+
- CACHE_TTL_SECONDS=300
|
| 25 |
+
- BUDGET_USD_PER_SESSION=10.0
|
| 26 |
+
- CIRCUIT_BREAKER_FAILURE_THRESHOLD=3
|
| 27 |
+
- CIRCUIT_BREAKER_RECOVERY_TIMEOUT=30
|
| 28 |
+
# NIM primary (cloud GPU)
|
| 29 |
+
- NIM_API_BASE=https://integrate.api.nvidia.com/v1
|
| 30 |
+
- NVIDIA_API_KEY=${NVIDIA_API_KEY:-}
|
| 31 |
+
# Cloudflare secondary fallback
|
| 32 |
+
- CLOUDFLARE_API_KEY=${CLOUDFLARE_API_KEY:-}
|
| 33 |
+
- CLOUDFLARE_ACCOUNT_ID=${CLOUDFLARE_ACCOUNT_ID:-}
|
| 34 |
+
# Fallback config
|
| 35 |
+
- FALLBACK_ENABLED=true
|
| 36 |
+
- FALLBACK_PRIMARY=nim
|
| 37 |
+
- FALLBACK_SECONDARY=cloudflare
|
| 38 |
+
# MLX local (runs on host Metal, not in container)
|
| 39 |
+
- MLX_ENABLED=false
|
| 40 |
+
- MLX_API_BASE=http://host.docker.internal:8000/v1
|
| 41 |
+
- LOG_LEVEL=INFO
|
| 42 |
+
depends_on:
|
| 43 |
+
redis:
|
| 44 |
+
condition: service_healthy
|
| 45 |
+
postgres:
|
| 46 |
+
condition: service_healthy
|
| 47 |
+
networks:
|
| 48 |
+
- ml_intern_network
|
| 49 |
+
healthcheck:
|
| 50 |
+
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
| 51 |
+
interval: 30s
|
| 52 |
+
timeout: 10s
|
| 53 |
+
retries: 3
|
| 54 |
+
start_period: 40s
|
| 55 |
+
restart: unless-stopped
|
| 56 |
+
|
| 57 |
+
worker:
|
| 58 |
+
build:
|
| 59 |
+
context: .
|
| 60 |
+
dockerfile: Dockerfile.prod
|
| 61 |
+
command: ["python", "-m", "production.worker"]
|
| 62 |
+
environment:
|
| 63 |
+
- REDIS_URL=redis://redis:6379
|
| 64 |
+
- DATABASE_URL=postgresql://ml_intern:ml_intern@postgres:5432/ml_intern
|
| 65 |
+
- LOG_LEVEL=INFO
|
| 66 |
+
depends_on:
|
| 67 |
+
redis:
|
| 68 |
+
condition: service_healthy
|
| 69 |
+
postgres:
|
| 70 |
+
condition: service_healthy
|
| 71 |
+
networks:
|
| 72 |
+
- ml_intern_network
|
| 73 |
+
restart: unless-stopped
|
| 74 |
+
|
| 75 |
+
redis:
|
| 76 |
+
image: redis:7-alpine
|
| 77 |
+
ports:
|
| 78 |
+
- "127.0.0.1:6379:6379"
|
| 79 |
+
volumes:
|
| 80 |
+
- redis_data:/data
|
| 81 |
+
command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
|
| 82 |
+
networks:
|
| 83 |
+
- ml_intern_network
|
| 84 |
+
healthcheck:
|
| 85 |
+
test: ["CMD", "redis-cli", "ping"]
|
| 86 |
+
interval: 10s
|
| 87 |
+
timeout: 3s
|
| 88 |
+
retries: 3
|
| 89 |
+
restart: unless-stopped
|
| 90 |
+
|
| 91 |
+
postgres:
|
| 92 |
+
image: postgres:16-alpine
|
| 93 |
+
ports:
|
| 94 |
+
- "127.0.0.1:5432:5432"
|
| 95 |
+
environment:
|
| 96 |
+
- POSTGRES_USER=ml_intern
|
| 97 |
+
- POSTGRES_PASSWORD=ml_intern
|
| 98 |
+
- POSTGRES_DB=ml_intern
|
| 99 |
+
volumes:
|
| 100 |
+
- postgres_data:/var/lib/postgresql/data
|
| 101 |
+
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
| 102 |
+
networks:
|
| 103 |
+
- ml_intern_network
|
| 104 |
+
healthcheck:
|
| 105 |
+
test: ["CMD-SHELL", "pg_isready -U ml_intern"]
|
| 106 |
+
interval: 10s
|
| 107 |
+
timeout: 3s
|
| 108 |
+
retries: 5
|
| 109 |
+
restart: unless-stopped
|
| 110 |
+
|
| 111 |
+
nginx:
|
| 112 |
+
image: nginx:alpine
|
| 113 |
+
ports:
|
| 114 |
+
- "80:80"
|
| 115 |
+
volumes:
|
| 116 |
+
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
| 117 |
+
depends_on:
|
| 118 |
+
- api
|
| 119 |
+
networks:
|
| 120 |
+
- ml_intern_network
|
| 121 |
+
restart: unless-stopped
|
| 122 |
+
|
| 123 |
+
volumes:
|
| 124 |
+
redis_data:
|
| 125 |
+
postgres_data:
|
| 126 |
+
|
| 127 |
+
networks:
|
| 128 |
+
ml_intern_network:
|
| 129 |
+
driver: bridge
|