-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
165 lines (158 loc) · 4.06 KB
/
docker-compose.yml
File metadata and controls
165 lines (158 loc) · 4.06 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
services:
# PostgreSQL
postgres-db:
image: postgres:17
container_name: postgres-db
environment:
POSTGRES_USER: ${DATABASE_USER}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_DB: ${DATABASE_NAME}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- backend
ports:
- "5432:5432"
# Redis
redis:
image: redis:latest
container_name: redis
networks:
- backend
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 30s
retries: 3
# FastAPI App (only this builds)
app:
build:
context: .
dockerfile: Dockerfile
image: my-fastapi-app:latest
container_name: fastapi_app
environment:
REDIS_URL: ${REDIS_URL}
WATCHFILES_FORCE_POLLING: "true"
SAM_CHECKPOINT: /app/checkpoints/sam_vit_h_4b8939.pth
SAM_MODEL_TYPE: vit_h
PROTOTYPE_DB_PATH: /app/data/known_fakes_embeddings.npy
PYTHONPATH: /app/backend
ports:
- "8000:8000"
volumes:
- ./backend:/app/backend
- ./uploads:/app/uploads
- ./pip_cache:/root/.cache/pip
- ./checkpoints:/app/checkpoints
mem_limit: 8g
depends_on:
- postgres-db
- redis
networks:
- backend
# Celery Frame Worker (reuses image)
celery-frame-worker:
image: my-fastapi-app:latest
# container_name: celery-frame-worker
working_dir: /app/backend
deploy:
replicas: ${FRAME_WORKER_COUNT:-1}
environment:
- CELERY_MODULE=${CELERY_MODULE}
- REDIS_URL=${REDIS_URL}
- PYTHONPATH=/app/backend
- SAM_CHECKPOINT=/app/checkpoints/sam_vit_h_4b8939.pth
- SAM_MODEL_TYPE=vit_h
- PROTOTYPE_DB_PATH=/app/data/known_fakes_embeddings.npy
volumes:
- ./backend:/app/backend
- ./pip_cache:/root/.cache/pip
- ./uploads:/app/uploads
- ./checkpoints:/app/checkpoints
depends_on:
- redis
- postgres-db
networks:
- backend
command: >
celery -A ${CELERY_MODULE}.celery_app worker
-Q frame_selection_queue
--loglevel=info
--concurrency=2
healthcheck:
test:
[
"CMD-SHELL",
"celery -A ${CELERY_MODULE}.celery_app inspect ping -t 1 | grep -q 'ok'",
]
interval: 30s
timeout: 30s
retries: 5
start_period: 120s
celery-detection-worker:
image: my-fastapi-app:latest
# hostname: detection_worker
working_dir: /app/backend
deploy:
replicas: ${DETECTION_WORKER_COUNT:-1}
environment:
- CELERY_MODULE=${CELERY_MODULE}
- REDIS_URL=${REDIS_URL}
- PYTHONPATH=/app/backend
- SAM_CHECKPOINT=/app/checkpoints/sam_vit_h_4b8939.pth
- SAM_MODEL_TYPE=vit_h
- PROTOTYPE_DB_PATH=/app/data/known_fakes_embeddings.npy
volumes:
- ./backend:/app/backend
- ./pip_cache:/root/.cache/pip
- ./uploads:/app/uploads
- ./checkpoints:/app/checkpoints
mem_limit: 8g
depends_on:
- redis
- postgres-db
networks:
- backend
command: celery -A ${CELERY_MODULE}.celery_app worker -Q deepfake_detection_queue --loglevel=info --concurrency=1
healthcheck:
test:
[
"CMD-SHELL",
"celery -A ${CELERY_MODULE}.celery_app inspect ping -t 1 | grep -q 'ok'",
]
interval: 30s
timeout: 30s
retries: 5
start_period: 120s
flower:
image: my-fastapi-app:latest
container_name: flower
working_dir: /app/backend
command: >
sh -c "sleep 10 && celery -A ${CELERY_MODULE}.celery_app flower --port=5555"
environment:
- CELERY_MODULE=${CELERY_MODULE}
- REDIS_URL=${REDIS_URL}
- CELERY_BROKER_URL=${CELERY_BROKER_URL}
- PYTHONPATH=/app/backend
volumes:
- ./backend:/app/backend
- ./pip_cache:/root/.cache/pip
- ./uploads:/app/uploads
ports:
- "5555:5555"
depends_on:
- celery-frame-worker
- redis
networks:
- backend
networks:
backend:
driver: bridge
volumes:
postgres_data:
pip-cache:
checkpoints: