-
Notifications
You must be signed in to change notification settings - Fork 14
/
docker-compose.ytt.min.yaml
360 lines (336 loc) · 12.3 KB
/
docker-compose.ytt.min.yaml
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
#@ load("@ytt:data", "data")
#@ load("@ytt:template", "template")
---
#@ def skill_image_name(skill):
#@ return "ukpsquare/skills-" + skill.name + ":" + data.values.tag
#@ end
#@ def skill_build(skill):
#@ return {"context": "./skills", "dockerfile": "./" + skill.name + ".Dockerfile"}
#@ end
#@ def skill_environment(skill):
WEB_CONCURRENCY: #@ str(data.values.web_concurrency)
VERIFY_SSL: #@ str(data.values.verify_ssl[data.values.environment])
SQUARE_API_URL: #@ data.values.square_api_url[data.values.environment]
KEYCLOAK_BASE_URL: #@ data.values.keycloak_base_url_https[data.values.environment]
REALM: #@ data.values.realm
CLIENT_ID: #@ skill.author + "-" + skill.name
#@ end
#@ def skill_env_file(skill):
#@ return ["./skills/" + skill.name + "/.env"]
#@ end
#@ def frontend_traefik_redirect():
#@ if data.values.environment == "production":
#@ return [
#@ "traefik.http.routers.frontend.rule=Host(`" + data.values.frontend_url[data.values.environment] + "`) || Host(`square.ukp.informatik.tu-darmstadt.de`)",
#@ "traefik.http.routers.frontend.middlewares=tuda-redirect",
#@ "traefik.http.middlewares.tuda-redirect.redirectregex.regex=^https://square.ukp.informatik.tu-darmstadt.de/(.*)",
#@ "traefik.http.middlewares.tuda-redirect.redirectregex.replacement=https://" + data.values.frontend_url[data.values.environment] + "/$${1}",
#@ "traefik.http.middlewares.tuda-redirect.redirectregex.permanent=true"
#@ ]
#@ else:
#@ return [
#@ "traefik.http.routers.frontend.rule=Host(`" + data.values.frontend_url[data.values.environment] + "`)"
#@ ]
#@ end
#@ end
#@ def traefik_tls(service):
#@ return [
#@ "traefik.http.routers." + service + ".entrypoints=websecure",
#@ "traefik.http.routers." + service + ".tls=true",
#@ "traefik.http.routers." + service + ".tls.certresolver=le"
#@ ]
#@ end
#@ def traefik_prefix(service):
#@ return [
#@ "traefik.http.routers." + service + ".rule=PathPrefix(`/api/" + service + "`)",
#@ "traefik.http.routers." + service + ".middlewares=" + service + "-stripprefix," + service + "-addprefix",
#@ "traefik.http.middlewares." + service + "-stripprefix.stripprefix.prefixes=/api/" + service,
#@ "traefik.http.middlewares." + service + "-addprefix.addPrefix.prefix=/api"
#@ ]
#@ end
#@ def model_environment():
WEB_CONCURRENCY: #@ str(data.values.web_concurrency)
VERIFY_ISSUER: #@ str(data.values.verify_issuer[data.values.environment])
KEYCLOAK_BASE_URL: #@ data.values.keycloak_base_url_https[data.values.environment]
#@ end
#@ def model_management_environment():
WEB_CONCURRENCY: #@ str(data.values.web_concurrency)
VERIFY_SSL: #@ str(data.values.verify_ssl[data.values.environment])
VERIFY_ISSUER: #@ str(data.values.verify_issuer[data.values.environment])
KEYCLOAK_BASE_URL: #@ data.values.keycloak_base_url_https[data.values.environment]
DOCKER_HOST_URL: #@ data.values.docker_host_url[data.values.os]
MODEL_API_IMAGE: #@ "ukpsquare/square-model-api-v1.1:" + data.values.tag
ONNX_VOLUME: model-inference_onnx-models
REALM: #@ data.values.realm
MONGO_HOST: mongodb
MONGO_PORT: 27017
#@ end
version: "3.4"
services:
traefik:
image: traefik:v2.8.7
container_name: traefik
command:
- --api.insecure=true
- --api.dashboard=true
- --log.level=DEBUG
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --accesslog=true
- --accesslog.format=json
- --accesslog.filepath=/var/log/traefik/access.log.json
- --certificatesresolvers.le.acme.tlschallenge=true
- --certificatesresolvers.le.acme.storage=/certificates/acme.json
- #@ "--certificatesresolvers.le.acme.email=" + data.values.email
#@ if/end data.values.environment == "local":
- --certificatesresolvers.le.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
labels:
- "traefik.enable=true"
#! Global redirect to https
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.middlewares=https-redirect"
#! Middleware redirect from HTTP to HTTPS
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.https-redirect.redirectscheme.permanent=true"
- traefik.http.routers.traefik.service=api@internal
- traefik.http.routers.traefik.middlewares=auth
- traefik.http.middlewares.auth.basicauth.users=admin:${SQUARE_ADMIN_PASSWORD}
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- traefik-public-certificates:/certificates
mongodb:
image: mongo:5.0.4
restart: always
volumes:
- mongo-data:/data/db
expose:
- 27017
env_file:
- ./mongodb/.env
rabbit:
hostname: rabbit
image: rabbitmq:3-management
ports:
- 5672:5672
- 15672:15672
env_file:
- ./rabbitmq/.env
redis:
image: redis:latest
ports:
- 6379:6379
env_file:
- .env
- ./redis/.env
command: [ "redis-server", "--requirepass ${REDIS_PASSWORD}" ]
main_model:
image: #@ "ukpsquare/model-inference-transformer:" + data.values.tag
build:
context: ./model-inference
args:
- MODEL_TYPE=transformer
command: uvicorn model_inference.main:app --host 0.0.0.0 --port 8000 --log-config logging.conf
env_file:
- ./rabbitmq/.env
- ./redis/.env
environment:
WEB_CONCURRENCY: #@ str(data.values.web_concurrency)
VERIFY_SSL: #@ str(data.values.verify_ssl[data.values.environment])
KEYCLOAK_BASE_URL: #@ data.values.keycloak_base_url_https[data.values.environment]
DOCKER_HOST_URL: #@ data.values.docker_host_url[data.values.os]
CONFIG_PATH: /model_configs
QUEUE: facebook-dpr-question_encoder-single-nq-base
CONFIG_VOLUME: square-core_model_configs
SQUARE_PRIVATE_KEY_FILE: /local_deploy/private_key.pem
volumes:
- ./.cache/:/etc/huggingface/.cache/
- model_configs:/model_configs
- onnx_models:/onnx_models
- ./local_deploy:/local_deploy
labels:
- "traefik.enable=true"
- "traefik.http.routers.model-dpr.rule=PathPrefix(`/api/main`)"
- "traefik.http.routers.model-dpr.entrypoints=websecure"
- "traefik.http.routers.model-dpr.tls=true"
- "traefik.http.routers.model-dpr.tls.certresolver=le"
- "traefik.http.routers.model-dpr.middlewares=model-dpr-stripprefix,model-dpr-addprefix"
- "traefik.http.middlewares.model-dpr-stripprefix.stripprefix.prefixes=/api/main"
- "traefik.http.middlewares.model-dpr-addprefix.addPrefix.prefix=/api"
tasb_worker:
image: #@ "ukpsquare/model-inference-sentence-transformer:" + data.values.tag
build:
context: ./model-inference
args:
- MODEL_TYPE=sentence_transformer
command: celery -A tasks worker -Q msmarco-distilbert-base-tas-b --loglevel=info
volumes:
- ./:/usr/src/app
- /var/run/docker.sock:/var/run/docker.sock
- model_configs:/model_configs
- ./local_deploy:/local_deploy
env_file:
- ./rabbitmq/.env
- ./redis/.env
- ./model-inference/model_configurations/.env.distilbert_sentence_transformer
environment:
WEB_CONCURRENCY: #@ str(data.values.web_concurrency)
VERIFY_SSL: #@ str(data.values.verify_ssl[data.values.environment])
KEYCLOAK_BASE_URL: #@ data.values.keycloak_base_url_https[data.values.environment]
DOCKER_HOST_URL: #@ data.values.docker_host_url[data.values.os]
ONNX_VOLUME: onnx_models
REALM: #@ data.values.realm
CONFIG_PATH: /model_configs
QUEUE: msmarco-distilbert-base-tas-b
SQUARE_PRIVATE_KEY_FILE: /local_deploy/private_key.pem
depends_on:
#! - maintaining
- rabbit
- redis
maintaining_worker:
build:
context: ./model-manager
dockerfile: ./Dockerfile
container_name: maintaining_worker
command: celery -A tasks worker --loglevel=info
volumes:
- ./:/usr/src/app
- /var/run/docker.sock:/var/run/docker.sock
- ./local_deploy:/local_deploy
env_file:
- ./rabbitmq/.env
- ./redis/.env
- ./model-manager/.env
environment:
WEB_CONCURRENCY: "2"
VERIFY_SSL: "0"
KEYCLOAK_BASE_URL: http://keycloak:8080
DOCKER_HOST_URL: https://172.17.0.1
MONGO_INITDB_ROOT_USERNAME: root
REALM: square
CLIENT_ID: models
CONFIG_VOLUME: square-core_model_configs
CONFIG_PATH: /model_configs
QUEUE: bert-base-uncased-pf-squad-onnx
SQUARE_PRIVATE_KEY_FILE: /local_deploy/private_key.pem
depends_on:
- maintaining
- rabbit
- redis
maintaining:
command: uvicorn model_manager.main:app --host 0.0.0.0 --port 9001 --log-config logging.conf
container_name: maintaining
build:
context: ./model-manager
dockerfile: Dockerfile
ports:
- 9001:9001
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./local_deploy:/local_deploy
links:
- mongodb
depends_on:
- mongodb
env_file:
- ./model-manager/.env
- ./rabbitmq/.env
- ./redis/.env
- ./mongodb/.env
environment:
WEB_CONCURRENCY: "2"
VERIFY_SSL: "0"
KEYCLOAK_BASE_URL: http://keycloak:8080
DOCKER_HOST_URL: https://172.17.0.1
CONFIG_PATH: /model_configs
CONFIG_VOLUME: square-core_model_configs
SQUARE_PRIVATE_KEY_FILE: /local_deploy/private_key.pem
REALM: square
CLIENT_ID: models
MONGO_HOST: mongodb
MONGO_PORT: 27017
labels:
- traefik.enable=true
- traefidk.http.routers.maintaining.rule=PathPrefix(`/api/models`)
- traefik.http.routers.maintaining.entrypoints=websecure
- traefik.http.routers.maintaining.tls=true
- traefik.http.routers.maintaining.tls.certresolver=le
- traefik.http.routers.maintaining.middlewares=maintaining-stripprefix,maintaining-addprefix
- traefik.http.middlewares.maintaining-stripprefix.stripPrefixRegex.regex=/api/models
- traefik.http.middlewares.maintaining-addprefix.addPrefix.prefix=/api
datastore_api:
privileged: true
image: #@ "ukpsquare/datastore:" + data.values.tag
build:
context: ./datastore-api
target: build
depends_on:
- datastore_es
- mongodb
ports:
- "7000:7000"
env_file:
- ./mongodb/.env
- ./datastore-api/.env
environment:
WEB_CONCURRENCY: #@ str(data.values.web_concurrency)
FAISS_PORT: 5000
MODEL_API_URL: #@ data.values.model_url[data.values.environment]
ES_URL: http://datastore_es:9200
KEYCLOAK_BASE_URL: #@ data.values.keycloak_base_url_https[data.values.environment]
REALM: #@ data.values.realm
VERIFY_ISSUER: #@ str(data.values.verify_issuer[data.values.environment])
VERIFY_SSL: #@ str(data.values.verify_ssl[data.values.environment])
MONGO_HOST: mongodb
MONGO_PORT: 27017
SQUARE_PRIVATE_KEY_FILE: /local_deploy/private_key.pem
volumes:
- ./local_deploy:/local_deploy
labels:
- "traefik.enable=true"
- #@ template.replace(traefik_tls("datastores"))
- "traefik.http.routers.datastores.rule=PathPrefix(`/api/datastores`)"
- "traefik.http.routers.datastores.middlewares=datastores-stripprefix,datastores-addprefix"
- "traefik.http.middlewares.datastores-stripprefix.stripPrefixRegex.regex=/api/[a-zA-Z0-9_-]+"
- "traefik.http.middlewares.datastores-addprefix.addPrefix.prefix=/datastores"
datastore_es:
mem_limit: 512m
image: docker.elastic.co/elasticsearch/elasticsearch:7.16.1
environment:
- discovery.type=single-node
volumes:
- datastore-api-es:/usr/share/elasticsearch/data
ports:
- 7200:9200
dozzle:
image: amir20/dozzle:v4.0.1
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
DOZZLE_NO_ANALYTICS: "true"
DOZZLE_LEVEL: DEBUG
DOZZLE_BASE: /admin/logs
labels:
- traefik.enable=true
- #@ template.replace(traefik_tls("dozzle"))
- traefik.http.routers.dozzle.rule=PathPrefix(`/admin/logs`)
- traefik.http.routers.dozzle.middlewares=auth
volumes:
traefik-public-certificates:
mongo-data:
driver: local
square-redis-data:
driver: local
datastore-api-es:
driver: local
model_configs:
driver: local
onnx_models:
driver: local