-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompose.yaml
402 lines (369 loc) · 12.6 KB
/
compose.yaml
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# Compose file for bringing up a simple local Divvi Up environment. This is not suitable for production!
x-janus-common: &janus_common
image: ${JANUS_AGGREGATOR_IMAGE:-us-west2-docker.pkg.dev/divviup-artifacts-public/janus/janus_aggregator:0.7.28}
restart: always
healthcheck:
test: ["CMD", "/bin/sh", "-c", "wget http://0.0.0.0:8000/healthz -O - >/dev/null"]
interval: 1s
retries: 10
depends_on:
janus_1_migrate:
condition: service_completed_successfully
janus_2_migrate:
condition: service_completed_successfully
x-janus-migrate: &janus_migrate
image: ${JANUS_MIGRATOR_IMAGE:-us-west2-docker.pkg.dev/divviup-artifacts-public/janus/janus_db_migrator:0.7.28}
command:
- migrate
- run
- --source
- /migrations
- --connect-timeout
- "60"
depends_on:
postgres:
condition: service_healthy
x-janus-environment: &janus_environment
RUST_LOG: info
PGPASSWORD: postgres
DATASTORE_KEYS: 1B6szboUUtMfyrLsIVE20g
AGGREGATOR_API_AUTH_TOKENS: "0000"
x-divviup-image: &divviup_image
image: ${DIVVIUP_API_IMAGE:-us-west2-docker.pkg.dev/divviup-artifacts-public/divviup-api/divviup_api_integration_test:0.4.1}
x-divviup-environment: &divviup_environment
RUST_LOG: info
AUTH_URL: https://auth.example
AUTH_CLIENT_ID: fake
AUTH_CLIENT_SECRET: fake
SESSION_SECRETS: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
DATABASE_ENCRYPTION_KEYS: heHIWC_qxHzdglI0VgLopQ
AUTH_AUDIENCE: https://app.example
APP_URL: http://localhost:8081
DATABASE_URL: postgres://postgres:postgres@postgres:5432/divviup
API_URL: http://localhost:8080
POSTMARK_TOKEN: fake
EMAIL_ADDRESS: the@from.address
services:
postgres:
image: docker.io/library/postgres:16
user: postgres
ports:
- "5432:5432"
healthcheck:
test:
- "CMD"
- "/bin/sh"
- "-c"
- |
psql postgres://postgres@127.0.0.1/divviup -c "" && \
psql postgres://postgres@127.0.0.1/janus_1 -c "" && \
psql postgres://postgres@127.0.0.1/janus_2 -c ""
interval: 1s
retries: 10
restart: always
environment:
POSTGRES_PASSWORD: postgres
configs:
- source: postgres_init
target: /docker-entrypoint-initdb.d/postgres_init.sql
divviup_api_migrate:
image: ${DIVVIUP_API_MIGRATOR_IMAGE:-us-west2-docker.pkg.dev/divviup-artifacts-public/divviup-api/divviup_api:0.4.1}
entrypoint:
- /migration
- up
environment:
DATABASE_URL: postgres://postgres:postgres@postgres:5432/divviup
depends_on:
postgres:
condition: service_healthy
pair_aggregator:
<<: *divviup_image
entrypoint:
- /bin/sh
- -c
- |
test -f /tmp/done || \
(/divviup --url=http://localhost:8080 --token="" \
aggregator create \
--name=leader --api-url=http://janus_1_aggregator:8080/aggregator-api \
--bearer-token=0000 \
--first-party --shared && \
/divviup --url=http://localhost:8080 --token="" \
account create demo && \
/divviup --url=http://localhost:8080 --token="" \
aggregator create \
--name=helper --api-url=http://janus_2_aggregator:8080/aggregator-api \
--bearer-token=0000 && \
touch /tmp/done)
network_mode: service:divviup_api
depends_on:
divviup_api:
condition: service_healthy
janus_1_aggregator:
condition: service_healthy
janus_2_aggregator:
condition: service_healthy
divviup_api:
<<: *divviup_image
healthcheck:
test: ["CMD", "/bin/sh", "-c", "wget http://0.0.0.0:8080/health -O - >/dev/null"]
interval: 1s
retries: 10
ports:
- "8080:8080"
environment:
<<: *divviup_environment
depends_on:
divviup_api_migrate:
condition: service_completed_successfully
# Run a second divviup_api just to serve static assets, so that users can browse to localhost:8081
# and play with the console. It'd be nice to do this from service divviup_api, but it only binds a
# single port and insists on serving assets and its API on distinct hostnames.
static_assets:
<<: *divviup_image
healthcheck:
test: ["CMD", "/bin/sh", "-c", "wget http://0.0.0.0:8081/health -O - >/dev/null"]
interval: 1s
retries: 10
ports:
- "8081:8081"
environment:
PORT: 8081
<<: *divviup_environment
# Hack: if the last service to be started exits with status 0, then `docker compose up --wait`
# treats that as a failure. So we force divviup_api_vite to start last. Another option would be
# to add a health check to pair_aggregator as in ([1]), but the timing is brittle (the main
# process has to last long enough for the health check to succeed at least once) so it's easier
# and more reliable to add this dependency.
#
# [1]: https://github.com/docker/compose/issues/11774
# https://github.com/docker/compose/issues/10596
depends_on:
pair_aggregator:
condition: service_completed_successfully
janus_1_migrate:
<<: *janus_migrate
environment:
DATABASE_URL: postgres://postgres:postgres@postgres:5432/janus_1
janus_1_aggregator:
<<: *janus_common
entrypoint:
- /bin/sh
- -c
# Crimes: janus_2_aggregator's DAP API is localhost:9002 in the divviup-api aggregator object,
# but that address is only valid in the host network, outside of Docker Compose. But we need
# various parts of janus_1 to be able to reach janus_2_aggregator there. So we run nc(1)
# alongside the Janus processes so that it listens on localhost:9002 and forwards traffic to
# janus_2_aggregator:8080, which _does_ exist on the Docker Compose network.
- |
nc -p 9002 -lk -e nc janus_2_aggregator 8080 & \
/janus_aggregator aggregator
configs:
- janus_1_aggregator.yaml
ports:
- "9001:8080"
environment:
CONFIG_FILE: /janus_1_aggregator.yaml
<<: *janus_environment
janus_1_aggregation_job_creator:
<<: *janus_common
entrypoint: ["/janus_aggregator", "aggregation_job_creator"]
configs:
- janus_1_aggregation_job_creator.yaml
environment:
CONFIG_FILE: /janus_1_aggregation_job_creator.yaml
<<: *janus_environment
janus_1_aggregation_job_driver:
<<: *janus_common
entrypoint:
- /bin/sh
- -c
- |
nc -p 9002 -lk -e nc janus_2_aggregator 8080 & \
/janus_aggregator aggregation_job_driver
configs:
- janus_1_aggregation_job_driver.yaml
environment:
CONFIG_FILE: /janus_1_aggregation_job_driver.yaml
<<: *janus_environment
janus_1_collection_job_driver:
<<: *janus_common
entrypoint:
- /bin/sh
- -c
- |
nc -p 9002 -lk -e nc janus_2_aggregator 8080 & \
/janus_aggregator collection_job_driver
configs:
- janus_1_collection_job_driver.yaml
environment:
CONFIG_FILE: /janus_1_collection_job_driver.yaml
<<: *janus_environment
janus_1_garbage_collector:
<<: *janus_common
entrypoint: ["/janus_aggregator", "garbage_collector"]
configs:
- janus_1_garbage_collector.yaml
environment:
CONFIG_FILE: /janus_1_garbage_collector.yaml
<<: *janus_environment
janus_2_migrate:
<<: *janus_migrate
environment:
DATABASE_URL: postgres://postgres:postgres@postgres:5432/janus_2
janus_2_aggregator:
<<: *janus_common
entrypoint: ["/janus_aggregator", "aggregator"]
configs:
- janus_2_aggregator.yaml
ports:
- "9002:8080"
environment:
CONFIG_FILE: /janus_2_aggregator.yaml
<<: *janus_environment
janus_2_aggregation_job_creator:
<<: *janus_common
entrypoint: ["/janus_aggregator", "aggregation_job_creator"]
configs:
- janus_2_aggregation_job_creator.yaml
environment:
CONFIG_FILE: /janus_2_aggregation_job_creator.yaml
<<: *janus_environment
janus_2_aggregation_job_driver:
<<: *janus_common
entrypoint: ["/janus_aggregator", "aggregation_job_driver"]
configs:
- janus_2_aggregation_job_driver.yaml
environment:
CONFIG_FILE: /janus_2_aggregation_job_driver.yaml
<<: *janus_environment
janus_2_collection_job_driver:
<<: *janus_common
entrypoint: ["/janus_aggregator", "collection_job_driver"]
configs:
- janus_2_collection_job_driver.yaml
environment:
CONFIG_FILE: /janus_2_collection_job_driver.yaml
<<: *janus_environment
janus_2_garbage_collector:
<<: *janus_common
entrypoint: ["/janus_aggregator", "garbage_collector"]
configs:
- janus_2_garbage_collector.yaml
environment:
CONFIG_FILE: /janus_2_garbage_collector.yaml
<<: *janus_environment
configs:
postgres_init:
content: |
CREATE DATABASE divviup;
CREATE DATABASE janus_1;
CREATE DATABASE janus_2;
janus_1_aggregator.yaml:
content: |
database:
url: "postgres://postgres@postgres:5432/janus_1"
health_check_listen_address: "0.0.0.0:8000"
listen_address: "0.0.0.0:8080"
max_upload_batch_size: 100
max_upload_batch_write_delay_ms: 250
batch_aggregation_shard_count: 32
aggregator_api:
path_prefix: "aggregator-api"
public_dap_url: "http://localhost:9001"
janus_1_aggregation_job_creator.yaml:
content: |
database:
url: "postgres://postgres@postgres:5432/janus_1"
health_check_listen_address: "0.0.0.0:8000"
batch_aggregation_shard_count: 32
tasks_update_frequency_secs: 10
aggregation_job_creation_interval_secs: 10
min_aggregation_job_size: 10
max_aggregation_job_size: 100
janus_1_aggregation_job_driver.yaml:
content: |
database:
url: "postgres://postgres@postgres:5432/janus_1"
health_check_listen_address: "0.0.0.0:8000"
job_discovery_interval_secs: 10
max_concurrent_job_workers: 10
worker_lease_duration_secs: 600
worker_lease_clock_skew_allowance_secs: 60
maximum_attempts_before_failure: 10
batch_aggregation_shard_count: 32
janus_1_collection_job_driver.yaml:
content: |
database:
url: "postgres://postgres@postgres:5432/janus_1"
health_check_listen_address: "0.0.0.0:8000"
job_discovery_interval_secs: 10
max_concurrent_job_workers: 10
worker_lease_duration_secs: 600
worker_lease_clock_skew_allowance_secs: 60
maximum_attempts_before_failure: 10
batch_aggregation_shard_count: 32
janus_1_garbage_collector.yaml:
content: |
database:
url: "postgres://postgres@postgres:5432/janus_1"
health_check_listen_address: "0.0.0.0:8000"
garbage_collection:
gc_frequency_s: 60
report_limit: 5000
aggregation_limit: 500
collection_limit: 50
janus_2_aggregator.yaml:
content: |
database:
url: "postgres://postgres@postgres:5432/janus_2"
health_check_listen_address: "0.0.0.0:8000"
listen_address: "0.0.0.0:8080"
max_upload_batch_size: 100
max_upload_batch_write_delay_ms: 250
batch_aggregation_shard_count: 32
aggregator_api:
path_prefix: "aggregator-api"
public_dap_url: "http://localhost:9002"
janus_2_aggregation_job_creator.yaml:
content: |
database:
url: "postgres://postgres@postgres:5432/janus_2"
health_check_listen_address: "0.0.0.0:8000"
batch_aggregation_shard_count: 32
tasks_update_frequency_secs: 10
aggregation_job_creation_interval_secs: 10
min_aggregation_job_size: 10
max_aggregation_job_size: 100
janus_2_aggregation_job_driver.yaml:
content: |
database:
url: "postgres://postgres@postgres:5432/janus_2"
health_check_listen_address: "0.0.0.0:8000"
job_discovery_interval_secs: 10
max_concurrent_job_workers: 10
worker_lease_duration_secs: 600
worker_lease_clock_skew_allowance_secs: 60
maximum_attempts_before_failure: 10
batch_aggregation_shard_count: 32
janus_2_collection_job_driver.yaml:
content: |
database:
url: "postgres://postgres@postgres:5432/janus_2"
health_check_listen_address: "0.0.0.0:8000"
job_discovery_interval_secs: 10
max_concurrent_job_workers: 10
worker_lease_duration_secs: 600
worker_lease_clock_skew_allowance_secs: 60
maximum_attempts_before_failure: 10
batch_aggregation_shard_count: 32
janus_2_garbage_collector.yaml:
content: |
database:
url: "postgres://postgres@postgres:5432/janus_2"
health_check_listen_address: "0.0.0.0:8000"
garbage_collection:
gc_frequency_s: 60
report_limit: 5000
aggregation_limit: 500
collection_limit: 50