Repository navigation
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
155 lines (144 loc) · 6.36 KB
/
Copy pathdocker-compose.yaml
File metadata and controls
155 lines (144 loc) · 6.36 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
# Local development and testing; NOT for deployments (see
# `deployment/README.md`). `docker compose up --build --wait` starts proTES,
# the Celery worker, MongoDB and RabbitMQ; `--profile monitoring` adds Flower.
# Only proTES (and Flower) are published, on the host's loopback interface;
# to publish them on other interfaces, or to reach MongoDB or RabbitMQ from
# the host, override `ports` in a `docker-compose.override.yaml`.
# MongoDB, RabbitMQ and Flower run the images of the Helm chart (`image` of
# `mongodb`, `broker` and `flower` in `deployment/values.yaml`), with the same
# references, as `tests/test_repository.py` checks: bump them in both files
# Settings shared by the app and the Celery worker (same image)
x-protes: &protes
image: protes:local
# Always build locally instead of pulling an image of that name
pull_policy: build
build:
context: .
dockerfile: Dockerfile
# App version (the build gets no Git metadata); `0.0.0.dev0` if unset.
# Plugins from the host's `PLUGINS` (not pinned by hash; see
# `docs/plugin-images.md`); none if unset
args:
SETUPTOOLS_SCM_PRETEND_VERSION: ${SETUPTOOLS_SCM_PRETEND_VERSION:-}
PLUGINS: ${PLUGINS:-}
restart: unless-stopped
# Development settings (`config.dev.yaml`, see `FOCA_CONFIG_OVERLAY`)
volumes:
- ./config.dev.yaml:/etc/protes/config.dev.yaml:ro
depends_on:
mongodb:
condition: service_healthy
rabbitmq:
condition: service_healthy
# Message broker URL with the RabbitMQ credentials, which default to
# `protes:protes` (RabbitMQ is not published); set `RABBITMQ_DEFAULT_USER`
# and `RABBITMQ_DEFAULT_PASS` on the host to change them, with URL-safe
# characters only (letters, digits, `-`, `.`, `_`, `~`), as they are used
# both as is and in the URL. RabbitMQ creates the user on its first start
# only: to change the credentials later, remove its volume (`docker compose
# down --volumes`, which also removes the database)
x-broker-url: &broker-url "pyamqp://${RABBITMQ_DEFAULT_USER:-protes}:${RABBITMQ_DEFAULT_PASS:-protes}@rabbitmq:5672//"
# The client of proTES at its identity provider, for TES backends with
# `auth: client_credentials` (see `docs/access-control.md`), from the host's
# `PROTES_CLIENT_ID` and `PROTES_CLIENT_SECRET`; backends with `auth: basic`
# need their variables added to both services
x-client-id: &client-id ${PROTES_CLIENT_ID:-}
x-client-secret: &client-secret ${PROTES_CLIENT_SECRET:-}
services:
protes:
<<: *protes
# Longer than Gunicorn's graceful timeout (20 seconds), which idle
# keep-alive connections (e.g., of browsers) use up on shutdown
stop_grace_period: 30s
ports:
- "127.0.0.1:8080:8080"
# The image's command serves the app with Gunicorn; options from the
# host's `GUNICORN_CMD_ARGS` (e.g., `--workers 2`) override its settings
# (not `--bind`, which would break the published port and health check)
environment:
CELERY_BROKER_URL: *broker-url
FOCA_CONFIG_OVERLAY: /etc/protes/config.dev.yaml
GUNICORN_CMD_ARGS: ${GUNICORN_CMD_ARGS:-}
PROTES_CLIENT_ID: *client-id
PROTES_CLIENT_SECRET: *client-secret
protes-worker:
<<: *protes
command: ["celery", "--app", "pro_tes.celery_worker", "worker", "--task-events", "--loglevel=info"]
environment:
CELERY_BROKER_URL: *broker-url
FOCA_CONFIG_OVERLAY: /etc/protes/config.dev.yaml
PROTES_CLIENT_ID: *client-id
PROTES_CLIENT_SECRET: *client-secret
# Replaces the image's health check, which probes the app
healthcheck:
test: ["CMD-SHELL", "celery --app pro_tes.celery_worker inspect ping --destination celery@$$HOSTNAME --timeout 10"]
interval: 30s
timeout: 20s
retries: 3
start_period: 30s
rabbitmq:
image: docker.io/library/rabbitmq:4.3.7
hostname: rabbitmq
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER:-protes}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS:-protes}
volumes:
- rabbitmq-data:/var/lib/rabbitmq
configs:
- source: rabbitmq-foca
target: /etc/rabbitmq/conf.d/90-foca.conf
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "--quiet", "ping"]
interval: 5s
timeout: 10s
retries: 12
start_period: 10s
mongodb:
# MongoDB 8.0 refuses to start on Linux kernels 6.19 to 7.0.13
# (https://jira.mongodb.org/browse/SERVER-121912)
image: docker.io/library/mongo:7.0.45
restart: unless-stopped
volumes:
- mongodb-data:/data/db
healthcheck:
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping').ok"]
interval: 5s
timeout: 5s
retries: 12
start_period: 10s
# Monitoring of the Celery worker (opt-in: `--profile monitoring`), which
# shows task arguments; requires basic authentication, set on the host as
# `FLOWER_BASIC_AUTH=<user>:<password>`
flower:
image: docker.io/mher/flower:2.0.1
profiles: [monitoring]
# Not restarted endlessly if `FLOWER_BASIC_AUTH` is unset
restart: on-failure:3
depends_on:
rabbitmq:
condition: service_healthy
entrypoint:
- sh
- -c
- >-
test -n "$${FLOWER_BASIC_AUTH}"
|| { echo "Set FLOWER_BASIC_AUTH (<user>:<password>)" >&2; exit 1; };
exec celery flower --port=5555
environment:
CELERY_BROKER_URL: *broker-url
FLOWER_BASIC_AUTH: ${FLOWER_BASIC_AUTH:-}
ports:
- "127.0.0.1:5555:5555"
# Config of RabbitMQ, as the chart's (FOCA's library chart): Celery declares
# transient non-exclusive queues (e.g., for the rpc:// result backend and
# remote control), which RabbitMQ 4.3 denies by default
configs:
rabbitmq-foca:
content: |
deprecated_features.permit.transient_nonexcl_queues = true
# Named volumes; data of earlier versions of this file, in
# `PROTES_DATA_DIR` (default `../data/pro_tes`), is not migrated
volumes:
mongodb-data:
rabbitmq-data: