1
- # version: '3.8' # Version is obsolete in Docker Compose v2+
2
-
3
1
services :
4
- # Interactive Setup Wizard (run once for initial configuration)
5
- setup :
6
- build :
7
- context : .
8
- dockerfile : docker/setup/Dockerfile
9
- container_name : rendiff_setup
10
- volumes :
11
- - .:/host # Mount the entire project directory
12
- - ./config:/app/config:ro # Mount config templates
13
- environment :
14
- - TERM=xterm-256color # Better terminal support
15
- profiles :
16
- - setup
17
- stdin_open : true
18
- tty : true
19
- networks :
20
- - rendiff
21
-
22
- # Traefik Reverse Proxy with HTTPS (runs by default)
2
+ # Traefik Reverse Proxy
23
3
traefik :
24
4
image : traefik:v3.0
25
- container_name : rendiff_traefik
5
+ container_name : ffmpeg_traefik
26
6
command :
27
7
- --configFile=/etc/traefik/traefik.yml
28
8
ports :
29
9
- " 80:80"
30
10
- " 443:443"
31
- - " 8081:8080" # Dashboard on 8081 to avoid conflict
11
+ - " 8081:8080"
32
12
volumes :
33
13
- /var/run/docker.sock:/var/run/docker.sock:ro
34
14
- ./traefik/traefik.yml:/etc/traefik/traefik.yml:ro
@@ -37,114 +17,84 @@ services:
37
17
depends_on :
38
18
- api
39
19
networks :
40
- - rendiff
20
+ - ffmpeg-net
41
21
restart : unless-stopped
42
22
labels :
43
23
- " traefik.enable=true"
44
24
- " traefik.http.routers.traefik-dashboard.rule=Host(`traefik.localhost`)"
45
25
- " traefik.http.routers.traefik-dashboard.entrypoints=websecure"
46
26
- " traefik.http.routers.traefik-dashboard.tls=true"
47
27
- " traefik.http.routers.traefik-dashboard.service=api@internal"
48
-
49
- # API Gateway (now behind Traefik)
50
- krakend :
51
- image : devopsfaith/krakend:2.6
52
- container_name : rendiff_gateway
53
- volumes :
54
- - ./config/krakend.json:/etc/krakend/krakend.json:ro
55
- # No port exposure - accessed through Traefik
56
- depends_on :
57
- - api
58
- networks :
59
- - rendiff
60
- restart : unless-stopped
61
- labels :
62
- - " traefik.enable=true"
63
- - " traefik.http.routers.krakend.rule=Host(`localhost`) && PathPrefix(`/`)"
64
- - " traefik.http.routers.krakend.entrypoints=websecure"
65
- - " traefik.http.routers.krakend.tls=true"
66
- - " traefik.http.services.krakend.loadbalancer.server.port=8080"
67
-
68
28
# Database Service
69
29
postgres :
70
30
image : postgres:15-alpine
71
- container_name : rendiff_postgres
31
+ container_name : ffmpeg_postgres
72
32
environment :
73
33
- POSTGRES_DB=ffmpeg_api
74
34
- POSTGRES_USER=ffmpeg_user
75
- - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
76
- - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
35
+ - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-defaultpassword}
77
36
volumes :
78
37
- postgres-data:/var/lib/postgresql/data
79
- - ./docker/postgres/init:/docker-entrypoint-initdb.d:ro
80
- # ports:
81
- # - "5432:5432" # Remove port exposure for security
38
+ ports :
39
+ - " 5432:5432"
82
40
networks :
83
- - rendiff
41
+ - ffmpeg-net
84
42
restart : unless-stopped
85
43
healthcheck :
86
44
test : ["CMD-SHELL", "pg_isready -U ffmpeg_user -d ffmpeg_api"]
87
45
interval : 10s
88
46
timeout : 5s
89
47
retries : 5
90
- command : >
91
- postgres
92
- -c max_connections=200
93
- -c shared_buffers=256MB
94
- -c effective_cache_size=1GB
95
- -c maintenance_work_mem=64MB
96
- -c checkpoint_completion_target=0.9
97
- -c wal_buffers=16MB
98
- -c default_statistics_target=100
99
- -c random_page_cost=1.1
100
- -c effective_io_concurrency=200
101
48
102
- # Database Migration Service (runs once to initialize schema)
49
+ # Queue Service (Redis)
50
+ redis :
51
+ image : redis:7-alpine
52
+ container_name : ffmpeg_redis
53
+ command : redis-server --appendonly yes
54
+ volumes :
55
+ - redis-data:/data
56
+ ports :
57
+ - " 6379:6379"
58
+ networks :
59
+ - ffmpeg-net
60
+ restart : unless-stopped
61
+ healthcheck :
62
+ test : ["CMD", "redis-cli", "ping"]
63
+ interval : 10s
64
+ timeout : 5s
65
+ retries : 5
66
+
67
+ # Database Migration Service
103
68
db-migrate :
104
69
build :
105
70
context : .
106
71
dockerfile : docker/api/Dockerfile
107
72
command : ["/app/scripts/docker-entrypoint.sh", "migrate"]
108
73
environment :
109
- - DATABASE_URL=${DATABASE_URL}
74
+ - DATABASE_URL=${DATABASE_URL:-postgresql://ffmpeg_user:defaultpassword@postgres:5432/ffmpeg_api }
110
75
- PYTHONUNBUFFERED=1
111
- - POSTGRES_HOST=postgres
112
- - POSTGRES_PORT=5432
113
- - POSTGRES_USER=ffmpeg_user
114
- - POSTGRES_DB=ffmpeg_api
115
76
depends_on :
116
77
postgres :
117
78
condition : service_healthy
118
79
networks :
119
- - rendiff
80
+ - ffmpeg-net
120
81
restart : " no"
121
- volumes :
122
- - ./alembic:/app/alembic:ro
123
- - ./alembic.ini:/app/alembic.ini:ro
124
82
125
83
# API Service
126
84
api :
127
85
build :
128
86
context : .
129
87
dockerfile : docker/api/Dockerfile
88
+ container_name : ffmpeg_api
130
89
environment :
131
- - DATABASE_URL=${DATABASE_URL}
90
+ - DATABASE_URL=${DATABASE_URL:-postgresql://ffmpeg_user:defaultpassword@postgres:5432/ffmpeg_api }
132
91
- REDIS_URL=redis://redis:6379/0
133
- - STORAGE_CONFIG=/app/config/storage.yml
134
92
- LOG_LEVEL=info
135
93
- PYTHONUNBUFFERED=1
136
94
- API_HOST=0.0.0.0
137
95
- API_PORT=8000
138
- - API_WORKERS=4
139
- - POSTGRES_HOST=postgres
140
- - POSTGRES_PORT=5432
141
- - POSTGRES_USER=ffmpeg_user
142
- - POSTGRES_DB=ffmpeg_api
143
- - REDIS_HOST=redis
144
- - REDIS_PORT=6379
145
96
volumes :
146
- - ./config:/app/config:ro
147
- - storage:/storage
97
+ - ./storage:/storage
148
98
depends_on :
149
99
postgres :
150
100
condition : service_healthy
@@ -153,176 +103,54 @@ services:
153
103
db-migrate :
154
104
condition : service_completed_successfully
155
105
networks :
156
- - rendiff
106
+ - ffmpeg-net
157
107
restart : unless-stopped
158
108
healthcheck :
159
- test : ["CMD", "/app/scripts/health-check.sh ", "api "]
109
+ test : ["CMD", "curl", "-f ", "http://localhost:8000/health "]
160
110
interval : 30s
161
111
timeout : 10s
162
- start_period : 120s
112
+ start_period : 60s
163
113
retries : 3
164
- deploy :
165
- replicas : 2
166
- resources :
167
- limits :
168
- cpus : ' 2'
169
- memory : 4G
114
+ labels :
115
+ - " traefik.enable=true"
116
+ - " traefik.http.routers.api.rule=Host(`localhost`) && PathPrefix(`/api`)"
117
+ - " traefik.http.routers.api.entrypoints=web"
118
+ - " traefik.http.services.api.loadbalancer.server.port=8000"
170
119
171
- # Worker Service - CPU
172
- worker-cpu :
120
+ # Worker Service - CPU Only
121
+ worker :
173
122
build :
174
123
context : .
175
124
dockerfile : docker/worker/Dockerfile
125
+ args :
126
+ - WORKER_TYPE=cpu
127
+ container_name : ffmpeg_worker
176
128
environment :
177
- - DATABASE_URL=${DATABASE_URL}
129
+ - DATABASE_URL=${DATABASE_URL:-postgresql://ffmpeg_user:defaultpassword@postgres:5432/ffmpeg_api }
178
130
- REDIS_URL=redis://redis:6379/0
179
- - STORAGE_CONFIG=/app/config/storage.yml
180
131
- WORKER_TYPE=cpu
181
132
- WORKER_CONCURRENCY=4
182
133
- LOG_LEVEL=info
183
134
- PYTHONUNBUFFERED=1
184
135
volumes :
185
- - ./config:/app/config:ro
186
- - storage:/storage
136
+ - ./storage:/storage
187
137
depends_on :
188
138
postgres :
189
139
condition : service_healthy
190
140
redis :
191
141
condition : service_healthy
192
142
networks :
193
- - rendiff
143
+ - ffmpeg-net
194
144
restart : unless-stopped
195
- deploy :
196
- replicas : 2
197
- resources :
198
- limits :
199
- cpus : ' 4'
200
- memory : 8G
201
-
202
- # Worker Service - GPU (optional)
203
- worker-gpu :
204
- build :
205
- context : .
206
- dockerfile : docker/worker/Dockerfile
207
- environment :
208
- - DATABASE_URL=${DATABASE_URL}
209
- - REDIS_URL=redis://redis:6379/0
210
- - STORAGE_CONFIG=/app/config/storage.yml
211
- - WORKER_TYPE=gpu
212
- - WORKER_CONCURRENCY=2
213
- - LOG_LEVEL=info
214
- - PYTHONUNBUFFERED=1
215
- - NVIDIA_VISIBLE_DEVICES=all
216
- volumes :
217
- - ./config:/app/config:ro
218
- - storage:/storage
219
- depends_on :
220
- postgres :
221
- condition : service_healthy
222
- redis :
223
- condition : service_healthy
224
- networks :
225
- - rendiff
226
- restart : unless-stopped
227
- deploy :
228
- replicas : 1
229
- resources :
230
- limits :
231
- cpus : ' 4'
232
- memory : 8G
233
- reservations :
234
- devices :
235
- - driver : nvidia
236
- count : 1
237
- capabilities : [gpu]
238
- profiles :
239
- - gpu
240
-
241
- # Queue Service (Redis)
242
- redis :
243
- image : redis:7-alpine
244
- container_name : rendiff_redis
245
- command : >
246
- redis-server
247
- --appendonly yes
248
- --appendfsync everysec
249
- --maxmemory 2gb
250
- --maxmemory-policy allkeys-lru
251
- --timeout 300
252
- --tcp-keepalive 300
253
- --maxclients 1000
254
- volumes :
255
- - redis-data:/data
256
- - ./docker/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro
257
- # ports:
258
- # - "6379:6379" # Remove port exposure for security
259
- networks :
260
- - rendiff
261
- restart : unless-stopped
262
- healthcheck :
263
- test : ["CMD", "redis-cli", "ping"]
264
- interval : 10s
265
- timeout : 5s
266
- retries : 5
267
-
268
-
269
- # Monitoring - Prometheus
270
- prometheus :
271
- image : prom/prometheus:v2.48.0
272
- command :
273
- - ' --config.file=/etc/prometheus/prometheus.yml'
274
- - ' --storage.tsdb.path=/prometheus'
275
- - ' --web.console.libraries=/usr/share/prometheus/console_libraries'
276
- - ' --web.console.templates=/usr/share/prometheus/consoles'
277
- volumes :
278
- - ./config/prometheus.yml:/etc/prometheus/prometheus.yml:ro
279
- - prometheus-data:/prometheus
280
- ports :
281
- - " 9090:9090"
282
- networks :
283
- - rendiff
284
- restart : unless-stopped
285
- profiles :
286
- - monitoring
287
-
288
- # Monitoring - Grafana
289
- grafana :
290
- image : grafana/grafana:10.2.0
291
- environment :
292
- - GF_SECURITY_ADMIN_USER=admin
293
- - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
294
- - GF_USERS_ALLOW_SIGN_UP=false
295
- volumes :
296
- - grafana-data:/var/lib/grafana
297
- - ./monitoring/dashboards:/etc/grafana/provisioning/dashboards:ro
298
- - ./monitoring/datasources:/etc/grafana/provisioning/datasources:ro
299
- ports :
300
- - " 3000:3000"
301
- networks :
302
- - rendiff
303
- restart : unless-stopped
304
- depends_on :
305
- - prometheus
306
- profiles :
307
- - monitoring
308
-
309
145
310
146
networks :
311
- rendiff :
147
+ ffmpeg-net :
312
148
driver : bridge
313
149
314
150
volumes :
315
151
storage :
316
152
driver : local
317
- driver_opts :
318
- type : none
319
- o : bind
320
- device : ${STORAGE_PATH:-./storage}
321
153
postgres-data :
322
154
driver : local
323
155
redis-data :
324
- driver : local
325
- prometheus-data :
326
- driver : local
327
- grafana-data :
328
156
driver : local
0 commit comments