forked from Traqora/astroml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
351 lines (336 loc) · 8.5 KB
/
Copy pathdocker-compose.prod.yml
File metadata and controls
351 lines (336 loc) · 8.5 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
version: '3.8'
# Production Docker Compose Override File
# Use with: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
services:
# PostgreSQL Database - Production
postgres:
image: postgres:15-alpine
container_name: astroml-postgres-prod
restart: always
environment:
POSTGRES_DB: ${POSTGRES_DB:-astroml}
POSTGRES_USER: ${POSTGRES_USER:-astroml}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C --shared-buffers=256MB --max-connections=200"
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./monitoring/postgres/backup:/backup
- ./migrations:/docker-entrypoint-initdb.d
networks:
- astroml-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-astroml} -d ${POSTGRES_DB:-astroml}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Redis - Production
redis:
image: redis:7-alpine
container_name: astroml-redis-prod
restart: always
command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
ports:
- "${REDIS_PORT:-6379}:6379"
networks:
- astroml-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
deploy:
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.25'
memory: 128M
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
networks:
astroml-network:
driver: bridge
volumes:
postgres_data:
volumes:
- redis_data:/data
networks:
- astroml-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
reservations:
cpus: '0.5'
memory: 512M
start_period: 10s
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Production application service
production:
environment:
- LOG_LEVEL=WARNING
- DEBUG=False
- APP_ENV=production
restart: always
deploy:
resources:
limits:
cpus: '4'
memory: 4G
reservations:
cpus: '2'
memory: 2G
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
# AstroML Ingestion Service
ingestion:
build:
context: .
dockerfile: Dockerfile
target: production
container_name: astroml-ingestion-prod
environment:
ASTROML_ENV: production
DATABASE_URL: postgresql://${POSTGRES_USER:-astroml}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-astroml}
REDIS_URL: redis://redis:6379/0
FEATURE_STORE_PATH: /app/feature_store
volumes:
- feature_store:/app/feature_store
- ./config:/app/config:ro
networks:
- astroml-network
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import astroml.ingestion; import astroml.features; print('OK')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
ingestion:
# Production ingestion service
restart: unless-stopped
environment:
- LOG_LEVEL=INFO
- APP_ENV=production
deploy:
resources:
limits:
cpus: '4.0'
memory: 8G
reservations:
cpus: '1.0'
memory: 2G
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
streaming:
# Production streaming service
restart: always
environment:
- LOG_LEVEL=INFO
- APP_ENV=production
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '1'
memory: 1G
# AstroML Training Service
training:
build:
context: .
dockerfile: Dockerfile
target: training
container_name: astroml-training-prod
environment:
ASTROML_ENV: production
DATABASE_URL: postgresql://${POSTGRES_USER:-astroml}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-astroml}
REDIS_URL: redis://redis:6379/0
FEATURE_STORE_PATH: /app/feature_store
CUDA_VISIBLE_DEVICES: ${CUDA_VISIBLE_DEVICES:-0}
volumes:
- feature_store:/app/feature_store
- ./config:/app/config:ro
- model_store:/app/models
networks:
- astroml-network
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import torch; import astroml.features; print('OK')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 120s
restart: unless-stopped
deploy:
resources:
limits:
cpus: '8.0'
memory: 32G
reservations:
cpus: '2.0'
memory: 4G
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
# Feature Store Service
feature-store:
build:
context: .
dockerfile: Dockerfile
target: feature-store
container_name: astroml-feature-store-prod
environment:
ASTROML_ENV: production
DATABASE_URL: postgresql://${POSTGRES_USER:-astroml}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-astroml}
REDIS_URL: redis://redis:6379/0
FEATURE_STORE_PATH: /app/feature_store
ports:
- "${FEATURE_STORE_PORT:-8000}:8000"
volumes:
- feature_store:/app/feature_store
networks:
- astroml-network
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "from astroml.features import create_feature_store; store = create_feature_store('/app/feature_store'); print('OK')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
restart: unless-stopped
deploy:
resources:
limits:
cpus: '2.0'
memory: 4G
reservations:
cpus: '0.5'
memory: 1G
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
prometheus:
# Production Prometheus with persistent storage
image: prom/prometheus:latest
restart: always
environment:
- PROMETHEUS_ARGS=--storage.tsdb.retention.time=30d --storage.tsdb.retention.size=50GB
volumes:
- ./monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./monitoring/prometheus/alert_rules.yml:/etc/prometheus/alert_rules.yml:ro
- prometheus_data:/prometheus
networks:
- astroml-network
profiles:
- monitoring
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '1'
memory: 1G
grafana:
# Production Grafana with persistent storage
image: grafana/grafana:latest
restart: always
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
- GF_USERS_ALLOW_SIGN_UP=false
- GF_LOG_LEVEL=warn
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
volumes:
- grafana_data:/var/lib/grafana
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning:ro
networks:
- astroml-network
depends_on:
- prometheus
profiles:
- monitoring
deploy:
resources:
limits:
cpus: '1'
memory: 1G
reservations:
cpus: '0.5'
memory: 512M
networks:
astroml-network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
volumes:
postgres_data:
driver: local
redis_data:
driver: local
volumes:
prometheus_data:
driver: local
grafana_data:
driver: local
feature_store:
driver: local
model_store:
driver: local
networks:
astroml-network:
driver: bridge