-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
204 lines (195 loc) · 5.09 KB
/
docker-compose.prod.yml
File metadata and controls
204 lines (195 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
version: '3.8'
services:
# Production database with backup
database:
image: postgres:15-alpine
container_name: llm-platform-db-prod
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- postgres_data_prod:/var/lib/postgresql/data
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
- ./backups:/backups
networks:
- llm-network-prod
restart: always
deploy:
resources:
limits:
memory: 2G
cpus: '1.0'
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 30s
timeout: 10s
retries: 5
# Production Redis with persistence
redis:
image: redis:7-alpine
container_name: llm-platform-redis-prod
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD} --maxmemory 1gb --maxmemory-policy allkeys-lru
volumes:
- redis_data_prod:/data
networks:
- llm-network-prod
restart: always
deploy:
resources:
limits:
memory: 1G
cpus: '0.5'
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 30s
timeout: 10s
retries: 5
# Production backend with security hardening
backend:
build:
context: .
dockerfile: Dockerfile.prod
container_name: llm-platform-backend-prod
environment:
- FLASK_ENV=production
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/${POSTGRES_DB}
- REDIS_URL=redis://:${REDIS_PASSWORD}@redis:6379/0
- OPENAI_API_KEY=${OPENAI_API_KEY}
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
- SECRET_KEY=${SECRET_KEY}
- JWT_SECRET_KEY=${JWT_SECRET_KEY}
- API_HOST=0.0.0.0
- API_PORT=5000
- LOG_LEVEL=WARNING
- CORS_ORIGINS=${CORS_ORIGINS}
volumes:
- ./models:/app/models:ro
- ./datasets:/app/datasets:ro
- ./logs:/app/logs
depends_on:
database:
condition: service_healthy
redis:
condition: service_healthy
networks:
- llm-network-prod
restart: always
deploy:
resources:
limits:
memory: 8G
cpus: '4.0'
replicas: 2
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/api/v1/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
# Production frontend with nginx
frontend:
build:
context: ./web_interface/frontend
dockerfile: Dockerfile.prod
container_name: llm-platform-frontend-prod
environment:
- REACT_APP_API_URL=/api/v1
depends_on:
backend:
condition: service_healthy
networks:
- llm-network-prod
restart: always
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/"]
interval: 30s
timeout: 10s
retries: 5
# Load balancer and reverse proxy
nginx:
image: nginx:alpine
container_name: llm-platform-nginx-prod
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- ./logs/nginx:/var/log/nginx
ports:
- "80:80"
- "443:443"
depends_on:
- backend
- frontend
networks:
- llm-network-prod
restart: always
deploy:
resources:
limits:
memory: 256M
cpus: '0.25'
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 5
# Monitoring with Prometheus
prometheus:
image: prom/prometheus:latest
container_name: llm-platform-prometheus
volumes:
- ./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'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
ports:
- "9090:9090"
networks:
- llm-network-prod
restart: always
profiles:
- monitoring
# Log aggregation with Grafana
grafana:
image: grafana/grafana:latest
container_name: llm-platform-grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
volumes:
- grafana_data:/var/lib/grafana
- ./monitoring/grafana/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./monitoring/grafana/datasources:/etc/grafana/provisioning/datasources:ro
ports:
- "3001:3000"
depends_on:
- prometheus
networks:
- llm-network-prod
restart: always
profiles:
- monitoring
networks:
llm-network-prod:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
volumes:
postgres_data_prod:
driver: local
redis_data_prod:
driver: local
prometheus_data:
driver: local
grafana_data:
driver: local