Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
306 lines (284 loc) · 14.5 KB
/
Copy pathdocker-compose.yml
File metadata and controls
306 lines (284 loc) · 14.5 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
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
# https://docs.docker.com/compose/
# https://docs.docker.com/compose/compose-file
# Production:
# # https://docs.docker.com/compose/production/
# # adds to all services "restart: always"
# docker compose -f docker-compose.yml -f production.yml up -d
# Development:
# # Mounts the local code for easy debugging with reloading
# docker compose -f docker-compose.yml -f development.yml up
# Site-specific overlay:
# docker compose -f docker-compose.yml -f production.yml -f deployments/mysite.yml up -d
# Container names will be prefixed with "qaboard-"
# Images are tagged per service: $QABOARD_IMAGE:<service>, by default ghcr.io/samsung/qaboard:backend...
# - GitHub CI publishes them there (.github/workflows/ci.yaml): <service>-<commit> for each commit on master,
# <service> once all its tests passed (the latest master), and <service>-<version> for each release (e.g. 1.2.0)
# - QABOARD_VERSION picks a version ($QABOARD_IMAGE:backend-$QABOARD_VERSION). deployments/deploy.py sets it.
# - QABOARD_IMAGE picks another registry: a mirror, the images a fork publishes (ghcr.io/<owner>/qaboard),
# or where your own CI pushes the images it builds.
# Usage:
# - The application is served on port 5151 by default
# - Your responsibility to setup another reverse proxy on top for SSL
# - The admin services (RabbitMQ, Flower, pgadmin) are only published on this host (127.0.0.1)
# - Secrets go in .env (see website/docs/start-server.mdx), e.g. QABOARD_DB_PASSWORD. deployments/deploy.py passes
# those that the compose files read with ${...} to compose (it uses --env-file, so compose doesn't read .env itself)
# General docker compose usage:
# docker compose up # start the whole stack
# docker compose up -d # ...as a daemon
# docker compose stop # stop the stack's containers
# docker compose down --volumes # [dangerous] remove the data too
# docker compose build web # build a single service
# docker compose logs -f web # logs! -t/--timestamps --tail=10
# docker compose run web env # "docker-run" commands from a service
# docker compose up --no-deps -d web # start a single service
volumes:
data: {} # git clones (and custom batches.yaml for now...)
db: {}
redis_data: {}
rabbitmq-data: {}
cache_cantaloupe: {} # cache for the iiif image server
# The default results storage, at /mnt/qaboard: runs that send their files over HTTP save them there (backend/config.py).
# Sites mount their own storage at /mnt/qaboard instead, in their overlay (website/docs/start-server.mdx).
results: {}
pgadmin: {}
# all builds still available for smooth upgrades
frontend_builds: {}
website_builds: {}
services:
# For all configuration options:
# https://hub.docker.com/_/postgres
# https://stackoverflow.com/questions/30848670/how-to-customize-the-configuration-file-of-the-official-postgresql-docker-image
db:
image: postgres:12-alpine
expose:
- "5432"
volumes:
- db:/var/lib/postgresql/data
- ./services/db:/opt
environment:
- POSTGRES_USER=qaboard
# Set QABOARD_DB_PASSWORD in .env, where the backend reads it too. It's only used when the database is created:
# to change the password of an existing database, also run ALTER USER (see website/docs/backend-admin/deployment.mdx)
- POSTGRES_PASSWORD=${QABOARD_DB_PASSWORD:-password}
- POSTGRES_DB=qaboard
healthcheck:
test: ["CMD-SHELL", "pg_isready -U qaboard -d qaboard"]
interval: 10s
timeout: 5s
retries: 5
backend:
image: "${QABOARD_IMAGE:-ghcr.io/samsung/qaboard}:backend${QABOARD_VERSION:+-$QABOARD_VERSION}"
build:
context: .
dockerfile: backend/Dockerfile
args:
# Sentry's release (see website/docs/backend-admin/monitoring.mdx)
- QABOARD_VERSION=${QABOARD_VERSION:-}
# Wait for the database to be ready - https://docs.docker.com/compose/startup-order/
command: ["./wait-for-it.sh", "${QABOARD_DB_HOST-db}:${QABOARD_DB_PORT-5432}", "--", "/qaboard/backend/init.sh"]
depends_on:
- db
- redis
expose:
- "3000"
volumes:
- data:/var/qaboard
- results:/mnt/qaboard
# Secrets (SECRET_KEY, GITLAB_ACCESS_TOKEN...) come from env files, not from `environment`:
# an entry without a value there, like `- SECRET_KEY`, would unset what env files define if the shell doesn't set it.
env_file:
- path: .env
required: false
environment:
- UWSGI_PROCESSES=2
- UWSGI_LISTEN_QUEUE_SIZE=100
- QABOARD_DB_HOST
- QABOARD_DB_PORT
- REDIS_HOST=redis
- REDIS_PORT=6379
- QABOARD_LOGIN_TYPE=${QABOARD_LOGIN_TYPE:-LOCAL} # LOCAL/LDAP/SAML
# Where the `qa batch` it starts (tuning, redo) reaches QA-Board: through the proxy, which serves the files they fetch
- QABOARD_HOST=${QABOARD_HOST:-proxy}
- QABOARD_LOGIN_REQUIRED=${QABOARD_LOGIN_REQUIRED:-} # true: users must sign in to see anything. Empty: as set in the admin panel
- QABOARD_LOGIN_RESTRICTED=${QABOARD_LOGIN_RESTRICTED:-} # true/false
- QABOARD_LOGIN_RESTRICTED_YAML=${QABOARD_LOGIN_RESTRICTED_YAML:-} # path
# User names or emails of admins, comma-separated: they're admins whatever the database says
- QABOARD_ADMINS=${QABOARD_ADMINS:-}
# off/warn/token: how runs sent by `qa` are authenticated. Empty: as set in the admin panel (default: off)
- QABOARD_INGEST_AUTH=${QABOARD_INGEST_AUTH:-}
# Comma-separated: Jenkins jobs anyone can start without a token, by text in their path, e.g. ALGO. Empty: as set in the admin panel
- QABOARD_JENKINS_ANONYMOUS_JOBS=${QABOARD_JENKINS_ANONYMOUS_JOBS:-}
# Set it for the proxy too: the runs' HTML files can't act as whoever opens them (website/docs/viewers.mdx)
- QABOARD_SANDBOX_HTML=${QABOARD_SANDBOX_HTML:-}
# Set in .env, not here (see above): single sign-on with OpenID Connect (QABOARD_OIDC_ISSUER, QABOARD_OIDC_CLIENT_ID,
# QABOARD_OIDC_CLIENT_SECRET, see website/docs/backend-admin/sign-in.mdx), and QABOARD_ENCRYPTION_KEY, that encrypts
# the secrets of the sign-in providers added in the admin panel (long random text, e.g. `openssl rand -base64 32`)
# Inside the Docker network: always 5672, whatever port the host publishes (QABOARD_PORT_RABBITMQ)
- CELERY_BROKER_URL=pyamqp://${QABOARD_RABBITMQ_USER:-guest}:${QABOARD_RABBITMQ_PASSWORD:-guest}@rabbitmq:5672//
- QABOARD_RUN_MIGRATIONS
# 0: don't run the server's jobs (Admin > Storage) next to uwsgi, if you run `qaboard-admin jobs worker` elsewhere
- QABOARD_JOBS_WORKER
# Used by docker and deployments/deploy.py to know when a replica is ready to serve traffic
healthcheck:
# Never through the http_proxy of the environment, it may not bypass localhost
test: ["CMD", "python", "-c", "import urllib.request as u; u.build_opener(u.ProxyHandler({})).open('http://127.0.0.1:3001/api/v1/health', timeout=5)"]
interval: 10s
timeout: 10s
retries: 3
start_period: 120s
# uwsgi finishes in-flight requests on SIGTERM, the jobs worker stops its job at the next check (it resumes later)
stop_grace_period: 60s
frontend:
image: "${QABOARD_IMAGE:-ghcr.io/samsung/qaboard}:frontend${QABOARD_VERSION:+-$QABOARD_VERSION}"
build:
# the root, to include website/release-notes/: see webapp/Dockerfile
context: .
dockerfile: webapp/Dockerfile
shm_size: 6gb
args:
# Sentry: the release, and where to upload the source maps (see website/docs/backend-admin/monitoring.mdx)
- QABOARD_VERSION=${QABOARD_VERSION:-}
- SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN:-}
- SENTRY_ORG=${SENTRY_ORG:-}
- SENTRY_PROJECT=${SENTRY_PROJECT:-}
- SENTRY_URL=${SENTRY_URL:-}
volumes:
- frontend_builds:/builds
# by default we assume you run the QA-Board on localhost, but will want to change this
environment:
- REACT_APP_QABOARD_HOST=http://localhost:5151
# Message broker used by the celery task scheduler
# https://hub.docker.com/_/rabbitmq
rabbitmq:
image: rabbitmq:3-management
# To store the data at a non-random location
hostname: rabbitmq-qaboard
volumes:
- rabbitmq-data:/var/lib/rabbitmq
# Celery workers run the shell commands of the tasks they get: anyone who can connect to RabbitMQ can run commands
# on them. Set a user and password in .env (URL-safe characters) before workers connect from other hosts.
# They're only used when the rabbitmq-data volume is created; later: rabbitmqctl add_user / change_password.
environment:
RABBITMQ_DEFAULT_USER: ${QABOARD_RABBITMQ_USER:-guest}
RABBITMQ_DEFAULT_PASS: ${QABOARD_RABBITMQ_PASSWORD:-guest}
ports:
# Only on this host by default. For Celery workers on other hosts: QABOARD_RABBITMQ_HOST_IP=0.0.0.0 (or an address of the host)
- ${QABOARD_RABBITMQ_HOST_IP:-127.0.0.1}:${QABOARD_PORT_RABBITMQ:-5672}:5672
# The management UI and API
- 127.0.0.1:${QABOARD_PORT_RABBITMQ_MNGT:-15672}:15672
# https://flower.readthedocs.io/en/latest/config.html#options
# Note: flower 2.x registers via the `celery.commands` entry point, so it is launched through celery. It shares the backend
# image (which installs flower>=2.1.0), so only backend needs building.
flower:
image: "${QABOARD_IMAGE:-ghcr.io/samsung/qaboard}:backend${QABOARD_VERSION:+-$QABOARD_VERSION}"
environment:
- CELERY_BROKER_URL=pyamqp://${QABOARD_RABBITMQ_USER:-guest}:${QABOARD_RABBITMQ_PASSWORD:-guest}@rabbitmq//
- CELERY_BROKER_API=http://${QABOARD_RABBITMQ_USER:-guest}:${QABOARD_RABBITMQ_PASSWORD:-guest}@rabbitmq:15672/api/
- FLOWER_PORT=8888
- FLOWER_URL_PREFIX=flower
# Flower can revoke tasks and shut the workers down, and nginx serves it at /flower/ to whoever reaches QA-Board:
# to ask for a login, set FLOWER_BASIC_AUTH=user:password in .env
- FLOWER_BASIC_AUTH
command: celery -A qaboard.runners.celery_app flower
ports:
# Only on this host (it's also at /flower/)
- "127.0.0.1:${QABOARD_PORT_FLOWER:-8888}:8888"
depends_on:
- backend
- rabbitmq
website:
image: "${QABOARD_IMAGE:-ghcr.io/samsung/qaboard}:website${QABOARD_VERSION:+-$QABOARD_VERSION}"
build:
# the root, to include the repository files the docs show: see website/Dockerfile
context: .
dockerfile: website/Dockerfile
shm_size: 4gb
# by default we assume you run the QA-Board on localhost, but will want to change this
args:
- QABOARD_URL=${QABOARD_URL:-http://localhost:5151}
# Docs for your site's users, from website/site-docs/$QABOARD_SITE/ (set in your env file)
- QABOARD_SITE=${QABOARD_SITE:-}
# Without network access: QABOARD_MEDIA=placeholder, or a mirror of the docs' media (docs-media/README.md)
- QABOARD_MEDIA=${QABOARD_MEDIA:-}
- QABOARD_MEDIA_BASE_URL=${QABOARD_MEDIA_BASE_URL:-}
# When a proxy blocks some of the media: QABOARD_MEDIA_MISSING=remote (readers load them) or placeholder
- QABOARD_MEDIA_MISSING=${QABOARD_MEDIA_MISSING:-}
volumes:
- website_builds:/builds
# nginx as reverse-proxy
# https://hub.docker.com/_/nginx
proxy:
image: "${QABOARD_IMAGE:-ghcr.io/samsung/qaboard}:proxy${QABOARD_VERSION:+-$QABOARD_VERSION}"
build:
context: services/nginx
# # https://github.com/docker-library/docs/tree/master/nginx#using-environment-variables-in-nginx-configuration
command: >-
/bin/bash -c "
set -e;
sh /tmp/etc/nginx/configure.sh;
exec $${NGINX_BIN:-nginx} -g 'daemon off;'
"
environment:
- NGINX_USER=nginx
# Set it for the backend too: the runs' HTML files can't act as whoever opens them (website/docs/viewers.mdx)
- QABOARD_SANDBOX_HTML=${QABOARD_SANDBOX_HTML:-}
ports:
- ${QABOARD_PORT_HTTP:-5151}:80
volumes:
- ./services/nginx:/tmp/etc/nginx
- frontend_builds:/builds:ro
- website_builds:/docs:ro
# nginx serves /s/<path> from /var/qaboard/<path>
- results:/var/qaboard/mnt/qaboard:ro
depends_on:
- backend
- cantaloupe
- flower
# IIIF image server to serve images as tiles
cantaloupe:
image: "${QABOARD_IMAGE:-ghcr.io/samsung/qaboard}:cantaloupe${QABOARD_VERSION:+-$QABOARD_VERSION}"
build:
context: ./services/cantaloupe
expose:
- "8182"
volumes:
- cache_cantaloupe:/var/cache/cantaloupe
- /srv/cantaloupe
- results:/repository/mnt/qaboard:ro
# It reads /iiif/2/<path> from /repository/<path>, like nginx serves /s/<path> from /var/qaboard/<path>: mount your
# results storage in your site overlay, read-only, at the same paths as for nginx (see website/docs/start-server.mdx)
# - /mnt/qaboard:/repository/mnt/qaboard:ro
# Not the host's whole filesystem: anyone who can reach /iiif/ could read the images there.
environment:
CANTALOUPE_MEM_START: 1g
CANTALOUPE_MEM_MAX: 2g
command: sh -c 'java -Dcantaloupe.config=/etc/cantaloupe.properties -Dcom.sun.media.jai.disableMediaLib=true -Xms$${CANTALOUPE_MEM_START} -Xmx$${CANTALOUPE_MEM_MAX} -jar /usr/local/cantaloupe/cantaloupe-$${VERSION}.jar'
# For convenience, we also bundle pgadmin
# Login at localhost:5050 with PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD: set them in .env
# Note: pgadmin ships with utilities at e.g. /usr/local/pgsql-12
# More configuration options, e.g. reverse proxying with nginx:
# https://www.pgadmin.org/docs/pgadmin4/development/container_deployment.html
pgadmin:
image: dpage/pgadmin4:9
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-user@domain.com}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-SuperSecret}
# copied to the account's storage, where servers.json's PassFile (/.pgpass) points
PGPASS_FILE: /pgadmin4/passfile
# if you want to host it under a subdirectory, add a location.proxy_pass to the nginx conf
# SCRIPT_NAME: /pgadmin
volumes:
- pgadmin:/root/.pgadmin
# https://www.pgadmin.org/docs/pgadmin4/development/import_export_servers.html
- ./services/pgadmin/servers.json:/pgadmin4/servers.json
- ./services/pgadmin/passfile:/pgadmin4/passfile
# Only on this host: it can read and change the whole database. From elsewhere: ssh -L 5050:localhost:5050 <host>,
# or serve it through nginx (like /pgadmin4/ in deployments/sirc/nginx/qaboard.conf)
ports:
- "127.0.0.1:${PGADMIN_PORT:-5050}:80"
redis:
image: redis:7
restart: always
command: redis-server --save 60 1 --loglevel warning
volumes:
- redis_data:/data