-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.yml
377 lines (356 loc) · 12.4 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
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
version: "3.8"
volumes: # Note these will be prefixed by affinda_ when created by docker compose
pgdata_selfhosted:
affinda_shared:
opensearch-data:
networks:
default:
name: affinda_selfhosted_shared
driver: bridge
ipam:
config:
- subnet: 192.168.34.0/24
services:
# Local dev containers
text_extraction:
image: 335594571162.dkr.ecr.ap-southeast-2.amazonaws.com/text_extraction:6.33.264
expose:
- "${TEXT_EXTRACTION_PORT:-5010}"
deploy:
replicas: 3
environment:
NUM_WORKERS: "1"
SENTRY_DSN_TYPE: "${SENTRY_DSN_TYPE:-DEV}"
SENTRY_ENABLED: "0"
SENTRY_ENVIRONMENT: "${SENTRY_ENVIRONMENT:-text_extraction-selfhosted}"
TEXT_EXTRACTION_PORT: "${TEXT_EXTRACTION_PORT:-5010}"
restart: always
ocr:
image: 335594571162.dkr.ecr.ap-southeast-2.amazonaws.com/ocr:6.33.264
expose:
- "${OCR_PORT:-5011}"
deploy:
replicas: 2 # Increase this if you convert a lot of images
environment:
NUM_WORKERS: "1"
OCR_PORT: "${OCR_PORT:-5011}"
SENTRY_DSN_TYPE: "${SENTRY_DSN_TYPE:-DEV}"
SENTRY_ENABLED: "0"
SENTRY_ENVIRONMENT: "${SENTRY_ENVIRONMENT:-ocr-selfhosted}"
restart: always
pdfkit:
image: 335594571162.dkr.ecr.ap-southeast-2.amazonaws.com/pdfkit:6.33.264
expose:
- "${PDFKIT_PORT:-5012}"
deploy:
replicas: 1 # Increase if you convert a lot html files
environment:
NUM_WORKERS: "1"
PDFKIT_PORT: "${PDFKIT_PORT:-5012}"
SENTRY_DSN_TYPE: "${SENTRY_DSN_TYPE:-DEV}"
SENTRY_ENABLED: "0"
SENTRY_ENVIRONMENT: "${SENTRY_ENVIRONMENT:-pdfkit-selfhosted}"
restart: always
pdf2html:
image: 335594571162.dkr.ecr.ap-southeast-2.amazonaws.com/pdf2html:6.33.264
expose:
- "${PDF2HTML_PORT:-5018}"
deploy:
replicas: 1 # Increase if you convert a lot pdf to html files
environment:
NUM_WORKERS: "1"
PDF2HTML_PORT: "${PDF2HTML_PORT:-5018}"
SENTRY_ENABLED: "0"
SENTRY_ENVIRONMENT: "${SENTRY_ENVIRONMENT:-pdf2html-selfhosted}"
restart: always
libre_office:
image: 335594571162.dkr.ecr.ap-southeast-2.amazonaws.com/libre_office:6.33.264
hostname: libreoffice
expose:
- "${LIBRE_OFFICE_PORT:-5013}"
deploy:
replicas: 2 # Increase this if you convert a lot of docx files
environment:
LIBRE_OFFICE_PORT: "${LIBRE_OFFICE_PORT:-5013}"
restart: always
ulimits:
core: # Disable core dumps
hard: 0
soft: 0
inference:
image: 335594571162.dkr.ecr.ap-southeast-2.amazonaws.com/affinda-inference-selfhosted-resumes:6.33.264
ports:
- "${TORCHSERVE_INFERENCE_PORT:-5014}:${TORCHSERVE_INFERENCE_PORT:-5014}"
- "${TORCHSERVE_MANAGEMENT_PORT:-5015}:${TORCHSERVE_MANAGEMENT_PORT:-5015}"
environment:
SENTRY_DSN_TYPE: "${SENTRY_DSN_TYPE:-DEV}"
SENTRY_ENABLED: "0"
SENTRY_ENVIRONMENT: "${SENTRY_ENVIRONMENT:-inference-selfhosted}"
TS_INFERENCE_ADDRESS: "http://0.0.0.0:${TORCHSERVE_INFERENCE_PORT:-5014}"
TS_MANAGEMENT_ADDRESS: "http://0.0.0.0:${TORCHSERVE_MANAGEMENT_PORT:-5015}"
TS_MODEL_CONFIG: >-
{
"resume-v4_en":{"1.0":{"defaultVersion":true,"minWorkers":3,"maxWorkers":3}},
"resume-v4_multi":{"1.0":{"defaultVersion":true,"minWorkers":1,"maxWorkers":1}}
}
ENABLE_API_PROXY: "1"
healthcheck:
# Will still use other defaults from inference.Dockerfile
start_period: 600s # 20 minutes, because we have to load all the models above
deploy:
# Remove the below to run on CPU only
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [ gpu, utility, compute ]
depends_on:
web:
condition: service_healthy
restart: always
db:
image: 335594571162.dkr.ecr.ap-southeast-2.amazonaws.com/affinda-db:6.33.264
restart: always
user: postgres
environment:
POSTGRES_DB: affinda
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_PORT_NUMBER: "${DB_PORT:-5432}"
healthcheck:
test: "pg_isready -q -d affinda -U postgres --port ${DB_PORT:-5432}"
interval: 2s
ports:
- "${DB_PORT:-5432}:${DB_PORT:-5432}"
volumes:
- pgdata_selfhosted:/var/lib/postgresql/data
redis:
image: 335594571162.dkr.ecr.ap-southeast-2.amazonaws.com/affinda-redis:6.33.264
ports:
- "6379:6379"
restart: always
# APPS Services
web:
image: 335594571162.dkr.ecr.ap-southeast-2.amazonaws.com/affinda-selfhosted:6.33.264
restart: always
ports:
- "${HOST_PORT:-80}:80"
environment:
APPS_MODE: "WEB_SELFHOSTED"
SENTRY_ENABLED: "${SENTRY_ENABLED:-0}"
SENTRY_DSN_TYPE: "${SENTRY_DSN_TYPE:-DEV}"
DJANGO_SECRET_KEY: "5TS1pUeIwzdPlpPunaEGiMyznTPWEH0nwwMHNg78kSb111BlqK9Juh123456789X"
DJANGO_SETTINGS_MODULE: "config.settings.selfhosted"
DJANGO_SUPERUSER_PASSWORD: "changeme"
API_ROOT_URL: "http://api.localhost:80"
HOME: "/opt/affinda"
PYTHONUNBUFFERED: "1"
SENTRY_ENVIRONMENT: "${SENTRY_ENVIRONMENT:-selfhosted}"
# DOCKER specific ENV VARS defaults are in config.settings.base
TEXT_EXTRACTION_PORT: "${TEXT_EXTRACTION_PORT:-5010}"
OCR_PORT: "${OCR_PORT:-5011}"
PDFKIT_PORT: "${PDFKIT_PORT:-5012}"
PDF2HTML_PORT: "${PDF2HTML_PORT:-5018}"
LIBRE_OFFICE_PORT: "${LIBRE_OFFICE_PORT:-5013}"
TORCHSERVE_INFERENCE_PORT: "${TORCHSERVE_INFERENCE_PORT:-5014}"
TORCHSERVE_MANAGEMENT_PORT: "${TORCHSERVE_MANAGEMENT_PORT:-5015}"
DB_LOCAL_CONNECTION_POOLING: "1"
DB_HOST: db
DB_NAME: affinda
DB_PASS: password
DB_PORT: "${DB_PORT:-5432}"
DB_SSL_MODE: disable
DB_USER: postgres
REDIS_PORT: "6379"
USE_ELASTICSEARCH: "1"
ELASTICSEARCH_HOST: "opensearch"
CELERY_TASK_SOFT_TIME_LIMIT: "${CELERY_TASK_SOFT_TIME_LIMIT:-60}"
CELERY_TASK_TIME_LIMIT: "${CELERY_TASK_TIME_LIMIT:-90}"
AUTO_REGISTER_MODELS: "1"
ALWAYS_CONVERT_PDF_TO_HTML: "${ALWAYS_CONVERT_PDF_TO_HTML:-0}"
# ENABLED_EXTRACTORS: set to "resume,resume-v4" for both older resume and new resume next gen models
ENABLED_EXTRACTORS: "${ENABLED_EXTRACTORS:-resume-v4}"
# Comma-seperated list of mapping data source names to skip during initial import
# MDS_TO_SKIP_IMPORT: "ESCO Occupations,ESCO Skills"
healthcheck:
test: "curl --fail http://localhost:80/status || exit 1"
interval: 5s
timeout: 20s
start_period: 1200s # 20 minutes, starting can take a while if applying migrations
retries: 10
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
opensearch:
condition: service_healthy
volumes:
- affinda_shared:/opt/shared/
celery_worker:
image: 335594571162.dkr.ecr.ap-southeast-2.amazonaws.com/affinda-selfhosted:6.33.264
restart: always
environment:
APPS_MODE: "CELERY_WORKER"
CELERY_POOL_TYPE: "prefork"
CELERY_WORKER_CONCURRENCY: "4"
SENTRY_ENABLED: "${SENTRY_ENABLED:-0}"
SENTRY_DSN_TYPE: "${SENTRY_DSN_TYPE:-DEV}"
DJANGO_SECRET_KEY: "5TS1pUeIwzdPlpPunaEGiMyznTPWEH0nwwMHNg78kSb111BlqK9Juh123456789X"
DJANGO_SETTINGS_MODULE: "config.settings.selfhosted"
DJANGO_SUPERUSER_PASSWORD: "changeme"
HOME: "/opt/affinda"
PYTHONUNBUFFERED: "1"
SENTRY_ENVIRONMENT: "${SENTRY_ENVIRONMENT:-selfhosted}"
# GPU specific params
PRELOAD_SMALL_MODELS: "True"
C_FORCE_ROOT: "1"
CELERY_DEBUG_LEVEL: "INFO"
# DOCKER specific ENV VARS defaults are in config.settings.base
TEXT_EXTRACTION_PORT: "${TEXT_EXTRACTION_PORT:-5010}"
OCR_PORT: "${OCR_PORT:-5011}"
PDFKIT_PORT: "${PDFKIT_PORT:-5012}"
PDF2HTML_PORT: "${PDF2HTML_PORT:-5018}"
LIBRE_OFFICE_PORT: "${LIBRE_OFFICE_PORT:-5013}"
TORCHSERVE_INFERENCE_PORT: "${TORCHSERVE_INFERENCE_PORT:-5014}"
TORCHSERVE_MANAGEMENT_PORT: "${TORCHSERVE_MANAGEMENT_PORT:-5015}"
DB_LOCAL_CONNECTION_POOLING: "1"
DB_HOST: db
DB_NAME: affinda
DB_PASS: password
DB_PORT: "${DB_PORT:-5432}"
DB_SSL_MODE: disable
DB_USER: postgres
REDIS_PORT: "6379"
USE_ELASTICSEARCH: "1"
ELASTICSEARCH_HOST: "opensearch"
CELERY_TASK_SOFT_TIME_LIMIT: "${CELERY_TASK_SOFT_TIME_LIMIT:-60}"
CELERY_TASK_TIME_LIMIT: "${CELERY_TASK_TIME_LIMIT:-90}"
AUTO_REGISTER_MODELS: "1"
ALWAYS_CONVERT_PDF_TO_HTML: "${ALWAYS_CONVERT_PDF_TO_HTML:-0}"
ENABLED_EXTRACTORS: "${ENABLED_EXTRACTORS:-resume-v4}"
healthcheck:
test: "curl --fail http://localhost:5099/readyz || exit 1"
interval: 2.5s
timeout: 5s
start_period: 60s # 1 minute
retries: 2
deploy:
replicas: 1
volumes:
- affinda_shared:/opt/shared/
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
web:
condition: service_healthy
ocr:
condition: service_healthy
text_extraction:
condition: service_healthy
pdfkit:
condition: service_healthy
pdf2html:
condition: service_healthy
libre_office:
condition: service_healthy
inference:
condition: service_healthy
opensearch:
condition: service_healthy
celery_beat:
image: 335594571162.dkr.ecr.ap-southeast-2.amazonaws.com/affinda-selfhosted:6.33.264
restart: always
environment:
APPS_MODE: "CELERY_BEAT"
CELERY_POOL_TYPE: "prefork"
CELERY_WORKER_CONCURRENCY: "1"
SENTRY_ENABLED: "${SENTRY_ENABLED:-0}"
SENTRY_DSN_TYPE: "${SENTRY_DSN_TYPE:-DEV}"
DJANGO_SECRET_KEY: "5TS1pUeIwzdPlpPunaEGiMyznTPWEH0nwwMHNg78kSb111BlqK9Juh123456789X"
DJANGO_SETTINGS_MODULE: "config.settings.selfhosted"
DJANGO_SUPERUSER_PASSWORD: "changeme"
HOME: "/opt/affinda"
PYTHONUNBUFFERED: "1"
# GPU specific params
PRELOAD_SMALL_MODELS: "False"
C_FORCE_ROOT: "1"
CELERY_DEBUG_LEVEL: "INFO"
SENTRY_ENVIRONMENT: "${SENTRY_ENVIRONMENT:-selfhosted}"
# DOCKER specific ENV VARS defaults are in config.settings.base
TEXT_EXTRACTION_PORT: "${TEXT_EXTRACTION_PORT:-5010}"
OCR_PORT: "${OCR_PORT:-5011}"
PDFKIT_PORT: "${PDFKIT_PORT:-5012}"
PDF2HTML_PORT: "${PDF2HTML_PORT:-5018}"
LIBRE_OFFICE_PORT: "${LIBRE_OFFICE_PORT:-5013}"
TORCHSERVE_INFERENCE_PORT: "${TORCHSERVE_INFERENCE_PORT:-5014}"
TORCHSERVE_MANAGEMENT_PORT: "${TORCHSERVE_MANAGEMENT_PORT:-5015}"
DB_LOCAL_CONNECTION_POOLING: "1"
DB_HOST: db
DB_NAME: affinda
DB_PASS: password
DB_PORT: "${DB_PORT:-5432}"
DB_SSL_MODE: disable
DB_USER: postgres
REDIS_PORT: "6379"
USE_ELASTICSEARCH: "1"
ELASTICSEARCH_HOST: "opensearch"
ENABLED_EXTRACTORS: "${ENABLED_EXTRACTORS:-resume-v4}"
deploy:
replicas: 1
volumes:
- affinda_shared:/opt/shared/
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
web:
condition: service_healthy
ocr:
condition: service_healthy
text_extraction:
condition: service_healthy
pdfkit:
condition: service_healthy
pdf2html:
condition: service_healthy
libre_office:
condition: service_healthy
inference:
condition: service_healthy
opensearch:
condition: service_healthy
opensearch:
image: opensearchproject/opensearch:2.8.0
restart: always
environment:
discovery.type: "single-node"
OPENSEARCH_JAVA_OPTS: "-Xms512m -Xmx512m" # minimum and maximum Java heap size, should be half of mem_limit
plugins.security.disabled: "true"
bootstrap.memory_lock: "true" # along with the memlock settings below, disables swapping
cluster.routing.allocation.disk.threshold_enabled: "false" # disables low disk watermark
deploy:
resources:
limits:
memory: 2g
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems
hard: 65536
ports:
- "9200:9200"
volumes:
- opensearch-data:/usr/share/opensearch/data
healthcheck:
test: "curl --fail 127.0.0.1:9200 || exit 1"
interval: 5s
timeout: 20s
retries: 10
start_period: 120s