-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcompose.yml
More file actions
389 lines (376 loc) · 10.6 KB
/
compose.yml
File metadata and controls
389 lines (376 loc) · 10.6 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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# Rendiff - Production-Grade Media Processing API (Powered by FFmpeg)
# Docker Compose Configuration
# Optimized for performance, security, and maintainability
name: rendiff
services:
# Traefik Reverse Proxy
traefik:
image: traefik:v3.1
container_name: rendiff_traefik
command:
- --configFile=/etc/traefik/traefik.yml
ports:
- "8880:80"
- "8443:443"
- "8881:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik/traefik.yml:/etc/traefik/traefik.yml:ro
- ./traefik/dynamic.yml:/etc/traefik/dynamic.yml:ro
- ./traefik/certs:/etc/traefik/certs:ro
depends_on:
- api
networks:
- rendiff-net
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik-dashboard.rule=Host(`traefik.localhost`)"
- "traefik.http.routers.traefik-dashboard.entrypoints=websecure"
- "traefik.http.routers.traefik-dashboard.tls=true"
- "traefik.http.routers.traefik-dashboard.service=api@internal"
# API Gateway (now behind Traefik)
krakend:
image: devopsfaith/krakend:2.7
container_name: rendiff_gateway
volumes:
- ./config/krakend.json:/etc/krakend/krakend.json:ro
# No port exposure - accessed through Traefik
depends_on:
- api
networks:
- rendiff-net
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.krakend.rule=Host(`localhost`) && PathPrefix(`/`)"
- "traefik.http.routers.krakend.entrypoints=websecure"
- "traefik.http.routers.krakend.tls=true"
- "traefik.http.services.krakend.loadbalancer.server.port=8080"
# Database Service
# WARNING: Default password is for DEVELOPMENT ONLY
# For production, use compose.prod.yml or set POSTGRES_PASSWORD in .env
postgres:
image: postgres:16-alpine
container_name: rendiff_postgres
environment:
POSTGRES_DB: rendiff
POSTGRES_USER: rendiff_user
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-dev_only_password_change_me}
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
POSTGRES_HOST_AUTH_METHOD: scram-sha-256
POSTGRES_INITDB_WALDIR: /var/lib/postgresql/waldir
volumes:
- postgres-data:/var/lib/postgresql/data
ports:
- "5433:5432"
networks:
- rendiff-net
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U rendiff_user -d rendiff"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
command: >
postgres
-c max_connections=200
-c shared_buffers=256MB
-c effective_cache_size=1GB
-c maintenance_work_mem=64MB
-c checkpoint_completion_target=0.9
-c wal_buffers=16MB
-c default_statistics_target=100
-c random_page_cost=1.1
-c effective_io_concurrency=200
-c max_wal_size=2GB
-c min_wal_size=1GB
-c log_statement=none
-c log_min_duration_statement=1000
# Queue Service (Redis)
redis:
image: redis:7.2-alpine
container_name: rendiff_redis
command: >
redis-server
--appendonly yes
--appendfsync everysec
--maxmemory 2gb
--maxmemory-policy allkeys-lru
--timeout 300
--tcp-keepalive 300
--maxclients 1000
--save 900 1
--save 300 10
--save 60 10000
--stop-writes-on-bgsave-error no
--rdbcompression yes
--rdbchecksum yes
volumes:
- redis-data:/data
- ./docker/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro
ports:
- "6380:6379"
networks:
- rendiff-net
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
# Database Migration Service
db-migrate:
build:
context: .
dockerfile: docker/api/Dockerfile
command: ["/app/scripts/docker-entrypoint.sh", "migrate"]
environment:
DATABASE_URL: postgresql://rendiff_user:dev_password_123@postgres:5432/rendiff_dev
REDIS_URL: redis://redis:6379/0
PYTHONUNBUFFERED: "1"
depends_on:
postgres:
condition: service_healthy
networks:
- rendiff-net
restart: "no"
# API Service
api:
build:
context: .
dockerfile: docker/api/Dockerfile
# platforms removed for local builds - enable for multi-arch CI builds
# Note: container_name removed to allow replicas > 1
environment:
DATABASE_URL: postgresql://rendiff_user:dev_password_123@postgres:5432/rendiff_dev
REDIS_URL: redis://redis:6379/0
STORAGE_CONFIG: /app/config/storage.yml
LOG_LEVEL: info
PYTHONUNBUFFERED: "1"
API_HOST: 0.0.0.0
API_PORT: "8000"
API_WORKERS: "4"
POSTGRES_HOST: postgres
POSTGRES_PORT: "5432"
POSTGRES_USER: rendiff_user
POSTGRES_DB: rendiff_dev
REDIS_HOST: redis
REDIS_PORT: "6379"
# Security headers
API_CORS_ORIGINS: ${API_CORS_ORIGINS:-"*"}
API_TRUSTED_HOSTS: ${API_TRUSTED_HOSTS:-"*"}
volumes:
- ./storage:/storage
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
db-migrate:
condition: service_completed_successfully
networks:
- rendiff-net
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "-s", "http://localhost:8000/api/v1/health"]
interval: 30s
timeout: 10s
start_period: 60s
retries: 3
deploy:
replicas: 2
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '1'
memory: 2G
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=Host(`localhost`) && PathPrefix(`/api`)"
- "traefik.http.routers.api.entrypoints=web"
- "traefik.http.services.api.loadbalancer.server.port=8000"
# Worker Service - CPU Only
worker:
build:
context: .
dockerfile: docker/worker/Dockerfile
args:
WORKER_TYPE: cpu
# platforms removed for local builds - enable for multi-arch CI builds
# Note: container_name removed to allow replicas > 1
environment:
DATABASE_URL: postgresql://rendiff_user:dev_password_123@postgres:5432/rendiff_dev
REDIS_URL: redis://redis:6379/0
STORAGE_CONFIG: /app/config/storage.yml
WORKER_TYPE: cpu
WORKER_CONCURRENCY: "4"
LOG_LEVEL: info
PYTHONUNBUFFERED: "1"
# Worker optimization
CELERY_WORKER_PREFETCH_MULTIPLIER: "1"
CELERY_TASK_ACKS_LATE: "true"
volumes:
- ./storage:/storage
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- rendiff-net
restart: unless-stopped
deploy:
replicas: 2
resources:
limits:
cpus: '4'
memory: 8G
reservations:
cpus: '2'
memory: 4G
restart_policy:
condition: on-failure
delay: 10s
max_attempts: 3
# Worker Service - GPU (optional)
worker-gpu:
build:
context: .
dockerfile: docker/worker/Dockerfile
args:
WORKER_TYPE: gpu
platforms:
- linux/amd64
container_name: rendiff_worker_gpu
environment:
DATABASE_URL: postgresql://rendiff_user:dev_password_123@postgres:5432/rendiff_dev
REDIS_URL: redis://redis:6379/0
STORAGE_CONFIG: /app/config/storage.yml
WORKER_TYPE: gpu
WORKER_CONCURRENCY: "2"
LOG_LEVEL: info
PYTHONUNBUFFERED: "1"
NVIDIA_VISIBLE_DEVICES: all
NVIDIA_DRIVER_CAPABILITIES: video,compute,utility
# Worker optimization
CELERY_WORKER_PREFETCH_MULTIPLIER: "1"
CELERY_TASK_ACKS_LATE: "true"
volumes:
- ./config:/app/config:ro
- ./storage:/storage
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- rendiff-net
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: '4'
memory: 8G
reservations:
cpus: '2'
memory: 4G
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
restart_policy:
condition: on-failure
delay: 10s
max_attempts: 3
profiles:
- gpu
# Monitoring - Prometheus
prometheus:
image: prom/prometheus:v2.54.0
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'
volumes:
- ./config/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
ports:
- "9090:9090"
networks:
- rendiff-net
restart: unless-stopped
profiles:
- monitoring
# Monitoring - Grafana
# WARNING: Default password is for DEVELOPMENT ONLY
grafana:
image: grafana/grafana:11.2.0
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:-dev_admin_change_me}
GF_USERS_ALLOW_SIGN_UP: "false"
GF_SECURITY_DISABLE_GRAVATAR: "true"
GF_SECURITY_COOKIE_SECURE: "true"
GF_SECURITY_COOKIE_SAMESITE: strict
GF_SECURITY_STRICT_TRANSPORT_SECURITY: "true"
volumes:
- grafana-data:/var/lib/grafana
- ./monitoring/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./monitoring/datasources:/etc/grafana/provisioning/datasources:ro
ports:
- "3000:3000"
networks:
- rendiff-net
restart: unless-stopped
depends_on:
- prometheus
profiles:
- monitoring
networks:
rendiff-net:
driver: bridge
driver_opts:
com.docker.network.bridge.name: br-rendiff
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
gateway: 172.28.0.1
volumes:
storage:
driver: local
postgres-data:
driver: local
driver_opts:
type: none
o: bind
device: ${POSTGRES_DATA_PATH:-./data/postgres}
redis-data:
driver: local
driver_opts:
type: none
o: bind
device: ${REDIS_DATA_PATH:-./data/redis}
prometheus-data:
driver: local
driver_opts:
type: none
o: bind
device: ${PROMETHEUS_DATA_PATH:-./data/prometheus}
grafana-data:
driver: local
driver_opts:
type: none
o: bind
device: ${GRAFANA_DATA_PATH:-./data/grafana}