-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdocker-compose.yml
319 lines (304 loc) · 8.83 KB
/
docker-compose.yml
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
version: '3.9'
services:
crawler:
image: basic_image_crawler
build: crypto_sentiment_demo_app/crawler
container_name: crypto_sentiment_demo_app-crawler-1
command: tail -f /dev/null # a dummy command to keep the container alive
volumes:
- ./:/root
profiles:
- production
depends_on:
- db
networks:
- postgres
labels:
ofelia.enabled: "true"
ofelia.job-exec.crawler.schedule: "0 0 */6 * * *" # At minute 0 past every 6th hour (Note: it starts with seconds, not minutes)
ofelia.job-exec.crawler.command: "python3 -m crypto_sentiment_demo_app.crawler.crawler"
model_inference_api:
image: basic_image_model_fast_api
build: crypto_sentiment_demo_app/model_inference_api
command: uvicorn crypto_sentiment_demo_app.model_inference_api.api.model:app --host model_inference_api --port 8001
volumes:
- ./:/root
ports:
- "8001:8001"
hostname: model_inference_api
healthcheck:
test: ["CMD", "curl", "-f", "http://model_inference_api:8001/health"]
interval: 10s
timeout: 10s
retries: 5
environment:
- MLFLOW_TRACKING_URI=http://mlflow:5000
- MLFLOW_S3_ENDPOINT_URL=http://nginx:9000
profiles:
- production
depends_on:
- minio
- nginx
- mlflow
networks:
- model_inference
- mlflow
- s3
model_scorer:
image: basic_image_model_scorer
build: crypto_sentiment_demo_app/model_scorer
command: tail -f /dev/null # a dummy command to keep the container alive
volumes:
- ./:/root
depends_on:
model_inference_api:
condition: service_healthy
crawler:
condition: service_started
db:
condition: service_healthy
links:
- model_inference_api
profiles:
- production
networks:
- model_inference
- postgres
labels:
ofelia.enabled: "true"
ofelia.job-exec.model_scorer.schedule: "0 15 */6 * * *" # At minute 15 past every 6th hour (Note: the format starts with seconds, instead of minutes.)
ofelia.job-exec.model_scorer.command: "python3 -m crypto_sentiment_demo_app.model_scorer.model_scorer"
data_provider:
image: basic_image_data_provider
build: crypto_sentiment_demo_app/data_provider
command: uvicorn crypto_sentiment_demo_app.data_provider.api:app --host data_provider --port 8002
environment:
- HOST=${HOST}
ports:
- "8002:8002"
volumes:
- ./:/root
hostname: data_provider
depends_on:
db:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://data_provider:8002/health"]
interval: 10s
timeout: 10s
retries: 5
profiles:
- production
networks:
- data_provider
- postgres
frontend:
image: react_frontend_image
build:
context: crypto_sentiment_demo_app/frontend
args:
- HOST=${HOST}
hostname: frontend
command: serve -s build -l ${REACT_FRONTEND_PORT}
environment:
- PORT=${REACT_FRONTEND_PORT}
ports:
- "${REACT_FRONTEND_PORT}:${REACT_FRONTEND_PORT}"
volumes:
- ./:/root
depends_on:
model_inference_api:
condition: service_healthy
data_provider:
condition: service_healthy
links:
- model_inference_api
- data_provider
profiles:
- production
networks:
- model_inference
- data_provider
train:
image: basic_image_train
build:
context: crypto_sentiment_demo_app/train
args:
USER_ID: "$USER"
GROUP_ID: "$GROUP"
dockerfile: Dockerfile-cpu
command: python3 crypto_sentiment_demo_app/train/train.py
depends_on:
- minio
- nginx
- mlflow
environment:
- MLFLOW_TRACKING_URI=http://mlflow:5000
- MLFLOW_S3_ENDPOINT_URL=http://nginx:9000
networks:
- mlflow
- s3
volumes:
- ./:/root
profiles:
- train
label_studio:
image: basic_image_label_studio
build: crypto_sentiment_demo_app/label_studio
container_name: crypto_sentiment_demo_app-label_studio
command:
- /bin/bash
- -c
- |
export LABEL_STUDIO_DISABLE_SIGNUP_WITHOUT_LINK=true
label-studio --username ${LABEL_STUDIO_USER} --password ${LABEL_STUDIO_PASSWORD} --user-token ${LABEL_STUDIO_ACCESS_TOKEN}
hostname: label_studio_api
ports:
- "${LABEL_STUDIO_PORT}:${LABEL_STUDIO_PORT}"
volumes:
- ./:/home/crypto_sentiment_demo_app
profiles:
- production
networks:
- postgres
labels:
ofelia.enabled: "true"
ofelia.job-exec.label_studio_import.schedule: "0 30 */6 * * *" # At minute 30 past every 6th hour (Note: the format starts with seconds, instead of minutes)
ofelia.job-exec.label_studio_import.command: "bash /home/crypto_sentiment_demo_app/crypto_sentiment_demo_app/label_studio/modify_tasks.sh -p crypto_label_project -m import -c entropy -n 8"
ofelia.job-exec.label_studio_export.schedule: "0 59 23 * * *" # Every day at 23:59
ofelia.job-exec.label_studio_export.command: "bash /home/crypto_sentiment_demo_app/crypto_sentiment_demo_app/label_studio/modify_tasks.sh -p crypto_label_project -m export"
db:
container_name: postgres
image: postgres
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_HOST: ${POSTGRES_HOST}
PGDATA: /data/postgres
volumes:
- ./volumes/postgres:/data/postgres
- ./crypto_sentiment_demo_app/database/docker_postgres_init.sql:/docker-entrypoint-initdb.d/docker_postgres_init.sql
- type: tmpfs # to shut up some permission errors, taken from here https://tinyurl.com/4y773dyv
target: /var/lib/postgresql/data/pg_stat_tmp
tmpfs:
# 256 Mb - beware the default, it's infinity(!)
size: 268435456
ports:
- "8432:5432"
profiles: ["production", "train"]
networks:
- postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 30s
timeout: 10s
retries: 5
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}
PGADMIN_CONFIG_SERVER_MODE: "True"
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "True"
volumes:
- ./volumes/pgadmin/:/var/lib/pgadmin
- ./crypto_sentiment_demo_app/database/docker_pgadmin_servers.json:/pgadmin4/servers.json
ports:
- "8050:80"
profiles:
- production
networks:
- postgres
entrypoint:
- "/bin/sh"
- "-c"
- "/bin/echo 'postgres:5432:*:${POSTGRES_USER}:${POSTGRES_PASSWORD}' > /tmp/pgpassfile && chmod 600 /tmp/pgpassfile && /entrypoint.sh"
minio:
container_name: minio
hostname: minio
image: quay.io/minio/minio:RELEASE.2022-05-08T23-50-31Z
command: server --console-address ":9001" /data/
expose:
- "9000"
- "9001"
networks:
- s3
environment:
MINIO_ROOT_USER: ${AWS_ACCESS_KEY_ID}
MINIO_ROOT_PASSWORD: ${AWS_SECRET_ACCESS_KEY}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
profiles: ["production", "train"]
volumes:
- ./minio/:/data
nginx:
image: nginx:1.19.2-alpine
container_name: nginx
hostname: nginx
volumes:
- ./conf/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "8900:9000"
- "8901:9001"
networks:
- s3
profiles: ["production", "train"]
depends_on:
- minio
mlflow:
restart: always
build: crypto_sentiment_demo_app/mlflow_server
container_name: mlflow_server
hostname: mlflow
ports:
- "8500:5000"
networks:
- postgres
- s3
- mlflow
depends_on:
- minio
- nginx
- db
environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_S3_BUCKET=${AWS_S3_BUCKET}
- MLFLOW_S3_ENDPOINT_URL=http://nginx:9000
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_HOST=${POSTGRES_HOST}
- POSTGRES_DB=${POSTGRES_DB}
profiles: ["production", "train"]
command: /mlflow/start.sh
scheduler:
image: mcuadros/ofelia:latest
depends_on:
- crawler
- model_scorer
- label_studio
- model_inference_api
command: daemon --docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
postgres:
driver: bridge
s3:
driver: bridge
model_inference:
driver: bridge
data_provider:
driver: bridge
mlflow:
driver: bridge
volumes:
postgres:
minio: