forked from WordPress/openverse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
328 lines (311 loc) · 8.06 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
version: "2.4"
# Common build configuration for Airflow
# Extension field, see https://docs.docker.com/compose/compose-file/compose-file-v3/#extension-fields
x-airflow-common: &airflow-common
profiles:
- catalog
restart: on-failure
depends_on:
- postgres
- s3
image: openverse_catalog
env_file:
- .env
- catalog/.env
build:
context: ./catalog/
target: cat
args: # Automatically inferred from env vars, unless specified
- REQUIREMENTS_FILE=requirements_dev.txt
- CATALOG_PY_VERSION
- CATALOG_AIRFLOW_VERSION
volumes:
- ./catalog:/opt/airflow/catalog
- catalog-cache:/home/airflow/.cache
services:
# Database used by the API
db:
profiles:
- ingestion_server
- api
image: postgres:13.2-alpine
ports:
- "50254:5432"
volumes:
- api-postgres:/var/lib/postgresql/data
env_file:
- docker/db/env.docker
healthcheck:
test: "pg_isready -U deploy -d openledger"
# Database used by the catalog
upstream_db:
profiles:
- catalog
- catalog_dependencies
- ingestion_server
- api
build:
context: ./docker/upstream_db/
target: db
image: openverse-upstream_db
expose:
- "5432"
volumes:
- catalog-postgres:/var/lib/postgresql/data
- ./sample_data:/sample_data
env_file:
- docker/upstream_db/env.docker
healthcheck:
test: "pg_isready -U deploy -d openledger"
s3:
profiles:
- catalog_dependencies
- catalog
image: minio/minio:latest
ports:
- "5010:5000"
- "5011:5001"
env_file:
- .env
- docker/minio/.env
# Create empty buckets on every container startup
# Note: $0 is included in the exec because "/bin/bash -c" swallows the first
# argument, so it must be re-added at the beginning of the exec call
entrypoint: >-
/bin/bash -c
"for b in $${BUCKETS_TO_CREATE//,/ }; do
echo \"Making bucket $$b\" && mkdir -p /data/$$b;
done &&
exec $$0 \"$$@\""
command: minio server /data --address :5000 --console-address :5001
volumes:
- minio:/data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5010/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
load_to_s3:
profiles:
- catalog_dependencies
- catalog
image: minio/mc:latest
env_file:
- .env
- docker/minio/.env
depends_on:
- s3
volumes:
# Buckets for testing provider data imported from s3 are subdirectories under
# /tests/s3-data/
- ./catalog/tests/s3-data:/data:rw
# Loop through subdirectories mounted to the volume and load them to s3/minio.
# This takes care of filesystem delays on some local dev environments that may make
# minio miss files included directly in the minio volume.
# More info here: https://stackoverflow.com/questions/72867045
# This does *not* allow for testing permissions issues that may come up in real AWS.
# And, if you remove files from /tests/s3-data, you will need to use `just down -v`
# and `just up` or `just recreate` to see the minio bucket without those files.
entrypoint: >
/bin/sh -c "
/usr/bin/mc config host add s3 http://s3:5000 $${AWS_ACCESS_KEY} $${AWS_SECRET_KEY};
cd /data;
for b in */ ; do
echo \"Loading bucket $$b\"
/usr/bin/mc mb --ignore-existing s3/$$b
/usr/bin/mc cp --r $$b s3/$$b
/usr/bin/mc ls s3/$$b;
done ;
exit 0;
"
# Dev changes for the scheduler
scheduler:
<<: *airflow-common
depends_on:
- upstream_db
- s3
command: scheduler
expose:
- "8793" # Used for fetching logs
environment:
# Upgrade the DB on startup
_AIRFLOW_DB_UPGRADE: "true"
_AIRFLOW_WWW_USER_CREATE: "true"
_AIRFLOW_WWW_USER_USERNAME: airflow
_AIRFLOW_WWW_USER_PASSWORD: airflow
_AIRFLOW_WWW_USER_FIRSTNAME: Air
_AIRFLOW_WWW_USER_LASTNAME: Flow
_AIRFLOW_WWW_USER_EMAIL: airflow@example.com
# Dev changes for the webserver container
webserver:
<<: *airflow-common
depends_on:
- upstream_db
- s3
- scheduler
command: webserver
ports:
- "${AIRFLOW_PORT}:8080"
plausible_db:
profiles:
- frontend
image: postgres:13.2-alpine
expose:
- "5432"
volumes:
- plausible-postgres:/var/lib/postgresql/data
env_file:
- ./docker/plausible_db/env.docker
healthcheck:
test: "pg_isready -U deploy -d plausible"
plausible_ch:
profiles:
- frontend
image: clickhouse/clickhouse-server:22.6-alpine
volumes:
- plausible-clickhouse:/var/lib/clickhouse
- ./docker/clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
- ./docker/clickhouse/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
ulimits:
nofile:
soft: 262144
hard: 262144
plausible:
profiles:
- frontend
image: plausible/analytics:latest
ports:
- "50288:8000"
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
depends_on:
- plausible_db
- plausible_ch
env_file:
- docker/plausible/env.docker
cache:
profiles:
- api
image: redis:4.0.14
ports:
- "50263:6379"
es:
profiles:
- ingestion_server
- api
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
ports:
- "50292:9200"
env_file:
- docker/es/env.docker
healthcheck:
test:
[
"CMD-SHELL",
"curl -si -XGET 'localhost:9200/_cluster/health?pretty' | grep -qE 'yellow|green'",
]
interval: 10s
timeout: 60s
retries: 10
ulimits:
nofile:
soft: 65536
hard: 65536
volumes:
- es-data:/usr/share/elasticsearch/data
web:
profiles:
- api
build:
context: ./api/
target: api
args: # Automatically inferred from env vars, unless specified
- SEMANTIC_VERSION=${SEMANTIC_VERSION:-v1.0.0}
- API_PY_VERSION
image: openverse-api
volumes:
- ./api:/api
ports:
- "50280:8000" # Django
- "50230:3000" # Sphinx (unused by default; see `sphinx-live` recipe)
depends_on:
- db
- es
- cache
env_file:
- api/env.docker
- api/.env
environment:
STATIC_ROOT: ${STATIC_ROOT:-}
MEDIA_ROOT: ${MEDIA_ROOT:-}
stdin_open: true
tty: true
ingestion_server:
profiles:
- ingestion_server
- api
build:
context: ./ingestion_server/
target: ing
args: # Automatically inferred from env vars, unless specified
- INGESTION_PY_VERSION
image: openverse-ingestion_server
command: gunicorn -c ./gunicorn.conf.py
ports:
- "50281:8001"
depends_on:
- db
- upstream_db
- es
- indexer_worker
volumes:
- ./ingestion_server:/ingestion_server
env_file:
- ingestion_server/env.docker
- ingestion_server/.env
stdin_open: true
tty: true
indexer_worker:
profiles:
- ingestion_server
- api
build:
context: ./ingestion_server/
target: ing
args: # Automatically inferred from env vars, unless specified
- INGESTION_PY_VERSION
image: openverse-ingestion_server
command: gunicorn -c ./gunicorn_worker.conf.py
expose:
- "8002"
depends_on:
- db
- upstream_db
- es
volumes:
- ./ingestion_server:/ingestion_server
env_file:
- ingestion_server/env.docker
stdin_open: true
tty: true
proxy:
profiles:
- api
image: nginx:alpine
ports:
- "50200:9080"
- "50243:9443"
environment:
HTTPS_PORT: 50243 # See `ports` mapping above.
depends_on:
- web
volumes:
- ./docker/nginx/templates:/etc/nginx/templates
- ./docker/nginx/certs:/etc/nginx/certs
volumes:
api-postgres:
catalog-postgres:
plausible-postgres:
plausible-clickhouse:
es-data:
minio:
catalog-cache: