-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
285 lines (274 loc) · 8.25 KB
/
Copy pathdocker-compose.yml
File metadata and controls
285 lines (274 loc) · 8.25 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
services:
backend:
image: ${DATASPACE_IMAGE:-dataspace-backend:local}
build: .
env_file: .env
container_name: "DataSpace"
volumes:
# User-uploaded media (MEDIA_ROOT = BASE_DIR/files/public). This is
# persistent data, not code -- it lives on the host and cannot be
# baked into the image. Dropping the old `.:/code` bind mount for the
# image-based deploy removed the app's only access to it, so every
# file field lookup (e.g. an organization logo's `size`) raised
# FileNotFoundError and errored the GraphQL queries the dashboard
# depends on. Mount only this subtree, never the whole tree -- a
# full `.:/code` mount would shadow the deployed image.
- ./files:/code/files
ports:
- "8000:8000"
depends_on:
backend_db:
condition: service_healthy
elasticsearch:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
logging:
options:
max-size: "10m"
max-file: "3"
# On prod-cds, backend_db/elasticsearch/redis below are NOT what's
# actually running -- ci-deploy.sh deliberately skips starting them
# when same-named containers already exist under the `dataexchange`
# superproject (see its own comment), which lives on a DIFFERENT
# default network (dataexchange_default) than this project's own
# (dataexbackend_default, this compose file's implicit default).
# Confirmed live: the currently-running DataSpace container only
# reaches them because of an undocumented `docker network connect
# dataexchange_default DataSpace` done by hand on the host at some
# point -- never captured here, and would NOT survive a fresh
# --force-recreate (confirmed: a real deploy's `release` container hit
# "could not translate host name backend_db" on a fresh network-less
# container). Joining both networks here covers both cases: a genuinely
# fresh host (where this file's own backend_db/elasticsearch/redis come
# up on `default`) and prod-cds (where the real ones live on
# dataexchange_default).
networks:
- default
- dataexchange_default
# One-off management commands (migrations, etc.) against the deployed
# image, without touching the running `backend` container. No
# container_name, so `docker compose run` can spin up a fresh instance
# even while `backend` is up. Never starts on a plain `up`.
release:
image: ${DATASPACE_IMAGE:-dataspace-backend:local}
build: .
env_file: .env
profiles: ["release"]
volumes:
# Same media mount as `backend` -- management commands run here too
# and some of them touch uploaded files.
- ./files:/code/files
depends_on:
backend_db:
condition: service_healthy
entrypoint: ["python", "manage.py"]
command: ["migrate", "--noinput"]
# See `backend`'s identical networks: block above for why both are needed.
networks:
- default
- dataexchange_default
backend_db:
image: "postgres:14.4"
env_file: .env
restart: always
container_name: "DataExBackendDb"
environment:
- POSTGRES_NAME=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- "54321:5432"
volumes:
- backend_db_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
logging:
options:
max-size: "10m"
max-file: "3"
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.12.2
restart: always
container_name: "DataExBackendElastic"
env_file: .env
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
- ELASTIC_PASSWORD=changeme
- xpack.security.enabled=true
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
cap_add:
- IPC_LOCK
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
healthcheck:
test: ["CMD-SHELL", "curl -s http://localhost:9200/_cluster/health | grep -vq '\"status\":\"red\"'"]
interval: 20s
timeout: 10s
retries: 3
start_period: 40s
logging:
options:
max-size: "10m"
max-file: "3"
redis:
image: "redis:alpine"
restart: always
command: redis-server
container_name: "DataExBackendRedis"
ports:
- "6379:6379"
volumes:
- redis-data:/data
healthcheck:
test: ["CMD-SHELL", "redis-cli ping | grep -q 'PONG'"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
logging:
options:
max-size: "10m"
max-file: "3"
telemetry_elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.16.2
container_name: telemetry_elasticsearch
restart: always
profiles: ["telemetry"]
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
- ELASTIC_PASSWORD=changeme
- xpack.security.enabled=true
volumes:
- tele-elasticsearch-data:/usr/share/elasticsearch/data
healthcheck:
interval: 10s
retries: 12
test:
curl -s http://localhost:9200/_cluster/health | grep -vq
'"status":"red"'
logging:
options:
max-size: "10m"
max-file: "3"
kibana:
image: docker.elastic.co/kibana/kibana:7.16.2
container_name: kibana
profiles: ["telemetry"]
environment:
ELASTICSEARCH_URL: "http://telemetry_elasticsearch:9200"
ELASTICSEARCH_HOSTS: '["http://telemetry_elasticsearch:9200"]'
ELASTICSEARCH_USERNAME: elastic
ELASTICSEARCH_PASSWORD: changeme
restart: always
depends_on:
telemetry_elasticsearch:
condition: service_healthy
ports:
- "5601:5601"
apm-server:
image: docker.elastic.co/apm/apm-server:7.16.2
container_name: apm-server
profiles: ["telemetry"]
user: apm-server
restart: always
command:
[
"--strict.perms=false",
"-e",
"-E",
"apm-server.host=0.0.0.0:8200",
"-E",
"apm-server.kibana.enabled=true",
"-E",
"apm-server.kibana.host=kibana:5601",
"-E",
"apm-server.kibana.username=elastic",
"-E",
"apm-server.kibana.password=changeme",
"-E",
"output.elasticsearch.hosts=['telemetry_elasticsearch:9200']",
"-E",
"output.elasticsearch.enabled=true",
"-E",
"output.elasticsearch.username=elastic",
"-E",
"output.elasticsearch.password=changeme",
]
depends_on:
telemetry_elasticsearch:
condition: service_healthy
cap_add: [ "CHOWN", "DAC_OVERRIDE", "SETGID", "SETUID" ]
cap_drop: [ "ALL" ]
healthcheck:
interval: 10s
retries: 12
test:
curl --write-out 'HTTP %{http_code}' --fail --silent --output /dev/null
http://localhost:8200/
logging:
options:
max-size: "10m"
max-file: "3"
otel-collector:
image: otel/opentelemetry-collector:latest
container_name: otel-collector
profiles: ["telemetry"]
restart: always
command: "--config=/etc/otel-collector-config.yaml"
volumes:
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml:ro
depends_on:
apm-server:
condition: service_healthy
ports:
- "4317:4317"
logging:
options:
max-size: "10m"
max-file: "3"
volumes:
backend_db_data:
name: backend_db_data
elasticsearch-data:
driver: local
tele-elasticsearch-data:
driver: local
redis-data:
driver: local
networks:
# The dataexchange superproject's default network on prod-cds -- external
# because this compose project doesn't own it. See the comment on
# `backend`'s networks: block above.
dataexchange_default:
external: true