-
-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
199 lines (190 loc) · 5.27 KB
/
docker-compose.prod.yml
File metadata and controls
199 lines (190 loc) · 5.27 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
x-common-env: &common-env
env_file:
- ${ENV_FILE:-.env.production}
services:
postgres:
<<: *common-env
image: postgis/postgis:17-3.5
platform: linux/amd64
container_name: pgsql
restart: always
environment:
POSTGRES_DB: ${POSTGRES_DB:-ai}
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- ${POSTGRES_DATA:-/opt/fair-app/data/postgres}:/var/lib/postgresql/data
ports:
- "127.0.0.1:5434:5432"
networks:
- backend-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
redis:
<<: *common-env
image: redis:8-alpine
platform: linux/amd64
container_name: redis
restart: always
command: redis-server --appendonly yes
volumes:
- ${REDIS_DATA:-/opt/fair-app/data/redis}:/data
ports:
- "127.0.0.1:6378:6379"
networks:
- backend-network
healthcheck:
test: ["CMD", "redis-cli", "-a", "ping"]
interval: 10s
timeout: 5s
retries: 5
backend-api:
<<: *common-env
image: ghcr.io/hotosm/fair-api:${TAG:-latest}
platform: linux/amd64
container_name: api
restart: always
command: python manage.py runserver_with_q 0.0.0.0:8000
ports:
- "127.0.0.1:8000:8000"
volumes:
- ${APP_LOGS:-/opt/fair-app/data/log}:/app/log
- ${RAMP_HOME:-/opt/fair-app/data/ramp}:/RAMP_HOME
- ${TRAINING_WORKSPACE:-/opt/fair-app/data/trainings}:/TRAINING_WORKSPACE
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
networks:
- backend-network
healthcheck:
test:
[
"CMD-SHELL",
'python -c "import sys, requests; r = requests.get(''http://127.0.0.1:8000/api/''); print(r); sys.exit(0 if r.status_code==200 else 1)"',
]
interval: 30s
timeout: 10s
retries: 2
deploy:
resources:
limits:
cpus: "2"
memory: 2G
backend-worker-cpu:
<<: *common-env
profiles: ["cpu"]
image: ghcr.io/hotosm/fair-worker:${TAG:-latest}-cpu
platform: linux/amd64
container_name: worker-cpu
restart: always
command: celery -A aiproject worker --loglevel=INFO --concurrency=1 -Q ramp_training,yolo_training
volumes:
- ${APP_LOGS:-/opt/fair-app/data/log}:/app/log
- ${RAMP_HOME:-/opt/fair-app/data/ramp}:/RAMP_HOME
- ${TRAINING_WORKSPACE:-/opt/fair-app/data/trainings}:/TRAINING_WORKSPACE
depends_on:
backend-api:
condition: service_healthy
redis:
condition: service_healthy
postgres:
condition: service_healthy
networks:
- backend-network
deploy:
resources:
limits:
cpus: "2"
memory: 4G
backend-worker-gpu:
<<: *common-env
profiles: ["gpu"]
image: ghcr.io/hotosm/fair-worker:${TAG:-latest}-gpu
platform: linux/amd64
container_name: worker-gpu
restart: always
command: celery -A aiproject worker --loglevel=INFO --concurrency=1 -Q ramp_training,yolo_training --pool=solo
volumes:
- ${APP_LOGS:-/opt/fair-app/data/log}:/app/log
- ${RAMP_HOME:-/opt/fair-app/data/ramp}:/RAMP_HOME
- ${TRAINING_WORKSPACE:-/opt/fair-app/data/trainings}:/TRAINING_WORKSPACE
depends_on:
backend-api:
condition: service_healthy
redis:
condition: service_healthy
postgres:
condition: service_healthy
networks:
- backend-network
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
limits:
memory: 8G
prediction-worker:
<<: *common-env
image: ghcr.io/hotosm/fair-offline-predictor:${TAG:-latest}
platform: linux/amd64
container_name: prediction-worker
restart: always
command: celery -A aiproject worker --loglevel=INFO --concurrency=1 -Q predictions --pool=solo
volumes:
- ${APP_LOGS:-/opt/fair-app/data/log}:/app/log
- ${RAMP_HOME:-/opt/fair-app/data/ramp}:/RAMP_HOME
- ${TRAINING_WORKSPACE:-/opt/fair-app/data/trainings}:/TRAINING_WORKSPACE
depends_on:
backend-api:
condition: service_healthy
redis:
condition: service_healthy
postgres:
condition: service_healthy
networks:
- backend-network
deploy:
resources:
limits:
cpus: "2"
memory: 4G
flower:
<<: *common-env
image: mher/flower:2.0.1
platform: linux/amd64
container_name: flower
restart: always
command: celery --broker=redis://${REDIS_HOST:-redis}:${REDIS_PORT:-6379}/0 flower --address=0.0.0.0 --port=5000 --basic_auth=${FLOWER_USER:-admin}:${FLOWER_PASSWORD:-admin}
ports:
- "127.0.0.1:5500:5000"
networks:
- backend-network
depends_on:
backend-api:
condition: service_healthy
profiles:
- cpu
- gpu
docs:
image: squidfunk/mkdocs-material
container_name: mkdocs
restart: unless-stopped
volumes:
- ./docs:/docs
- ./mkdocs.yml:/mkdocs.yml
ports:
- "8001:8000"
command: serve -a 0.0.0.0:8000
networks:
- backend-network
networks:
backend-network:
driver: bridge