Repository navigation
Expand file tree
/
Copy pathdocker-compose.defaults.yaml
More file actions
378 lines (368 loc) · 14.5 KB
/
Copy pathdocker-compose.defaults.yaml
File metadata and controls
378 lines (368 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
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
# Canonical stack wiring (services, healthchecks, volume names). Do not edit on
# site deploys — copy docker-compose.yaml.example to docker-compose.yaml (gitignored)
# and set bind device: paths there; that file include:s this defaults file.
name: hpcperfstats
# Container stdout/stderr for `docker compose logs` (not host syslog/journald).
# Use json-file (not Docker-only ``local``) so Podman accept the driver too.
# max-size: rotate each file at 100 MiB; max-file: keep this many rotated files
# per container (~300 MiB cap with max-file: "3").
x-logging: &hpc-logging
driver: json-file
options:
max-size: "100m"
max-file: "3"
services:
web:
build:
# Context stays checkout root so COPY paths (hpcperfstats/, .git, …) resolve.
context: ./
dockerfile: services-conf/pipeline_web.Dockerfile
target: hpcperfstats-full
# Optional override for staff SPA commit link. Primary bake uses context .git
# (frontend-builder COPY + git rev-parse). Default unknown falls back to .git.
args:
HPCPERFSTATS_GIT_COMMIT: ${HPCPERFSTATS_GIT_COMMIT:-unknown}
image: hpcperfstats
pull_policy: never
restart: always
logging: *hpc-logging
command: /home/hpcperfstats/services-conf/django_startup.sh
environment:
- HPCPERFSTATS_INI=/home/hpcperfstats/hpcperfstats.ini
- STATIC_ROOT=/home/hpcperfstats/staticfiles
- STATICFILES_RAM_ROOT=/home/hpcperfstats/staticfiles-ram
- MEDIAFILES_RAM_ROOT=/home/hpcperfstats/media-ram
stop_grace_period: ${HPCPERFSTATS_WEB_STOP_GRACE:-30s}
volumes:
- staticfiles_data:/home/hpcperfstats/staticfiles
- media_data:/home/hpcperfstats/hpcperfstats/site/hpcperfstats_site/media
- staticfiles_ram:/home/hpcperfstats/staticfiles-ram
- media_ram:/home/hpcperfstats/media-ram
- hpcperfstatsdata:/hpcperfstats/
- valkey_runtime:/run/valkey
- postgres_runtime:/run/postgresql
networks:
hpcperfstats_net:
aliases:
- web
pipeline:
image: hpcperfstats
pull_policy: never
restart: always
logging: *hpc-logging
# cgroup memory.max for sync_timedb / supervisord: set mem_limit/memswap_limit
# per site in docker-compose.yaml (commented in .example; 128g fits ~192-251 GiB
# hosts with no swap). Without it memory.max is `max` and ingest has no budget.
# OOM preference (+500, inherited by every daemon) is set by supervisor_startup.sh;
# podman-compose ignores a compose oom_score_adj key.
stop_grace_period: ${HPCPERFSTATS_PIPELINE_STOP_GRACE:-480s}
depends_on:
- web
command: /home/hpcperfstats/services-conf/supervisor_startup.sh
environment:
- HPCPERFSTATS_INI=/home/hpcperfstats/hpcperfstats.ini
ports:
- "${HPCPERFSTATS_SYSLOG_PORT:-514}:514/udp"
- "${HPCPERFSTATS_SYSLOG_PORT:-514}:514/tcp"
volumes:
- hpcperfstatsdata:/hpcperfstats/
- ssh_keys:/hpcperfstats/.ssh/:ro
- valkey_runtime:/run/valkey
- postgres_runtime:/run/postgresql
networks:
hpcperfstats_net:
aliases:
- pipeline
valkey:
image: docker.io/valkey/valkey:9.2.0-alpine3.24
logging: *hpc-logging
# command[0] must stay valkey-server: the image entrypoint drops root to
# the valkey user only for that argv[0].
command:
- valkey-server
- --appendonly
- "no"
- --maxmemory
- 16gb
- --maxmemory-policy
- volatile-lru
- --io-threads
- "4"
- --unixsocket
- /run/valkey/valkey.sock
- --unixsocketperm
- "777"
volumes:
- valkey_runtime:/run/valkey
- ./services-conf/valkey_entrypoint.sh:/usr/local/bin/hps-valkey-entrypoint.sh:ro
entrypoint:
- /bin/sh
- /usr/local/bin/hps-valkey-entrypoint.sh
healthcheck:
test:
- CMD-SHELL
- valkey-cli ping && valkey-cli -s /run/valkey/valkey.sock ping
interval: 5s
timeout: 3s
retries: 10
networks:
hpcperfstats_net:
aliases:
- valkey
proxy:
build:
context: ./
dockerfile: services-conf/proxy.Dockerfile
args:
# TLS PEMs materialized at container start from proxy_ssl_source settings volume.
# No additional_contexts / no .env for TLS paths.
image: hpcperfstats-proxy
pull_policy: never
restart: always
logging: *hpc-logging
depends_on:
web:
condition: service_started
healthcheck:
# Only validate that nginx is accepting TCP connections.
# TLS may not be ready yet (certs), and some routes may return 4xx.
test:
- CMD-SHELL
- nc -z 127.0.0.1 80 || exit 1
interval: 5s
timeout: 3s
retries: 10
ports:
- "${HPCPERFSTATS_HTTP_PORT:-80}:80"
- "${HPCPERFSTATS_HTTPS_PORT:-443}:443"
volumes:
# TLS source mount (device: in docker-compose.yaml → proxy_ssl_source).
# Entrypoint materializes PEMs into /etc/ssl/hpcperfstats before nginx -t.
- proxy_ssl_source:/mnt/ssl-source:ro
# Main process/http defaults + vhost. Shared routing/security snippets:
# compose mounts are the only source of truth (proxy.Dockerfile does not
# COPY those snippets). hps-proxy-allowed-hosts.inc and nginx-resolver.inc
# stay image/runtime-managed.
- ./services-conf/nginx-main.conf:/etc/nginx/nginx.conf:ro
- ./services-conf/nginx.conf:/etc/nginx/http.d/default.conf:ro
- ./services-conf/nginx-static-files.conf:/etc/nginx/nginx-static-files.conf:ro
- ./services-conf/nginx-api-route-allowlist.inc:/etc/nginx/nginx-api-route-allowlist.inc:ro
- ./services-conf/nginx-django-proxy-common.inc:/etc/nginx/nginx-django-proxy-common.inc:ro
- ./services-conf/nginx-compress-proxy.inc:/etc/nginx/nginx-compress-proxy.inc:ro
- ./services-conf/nginx-compress-static.inc:/etc/nginx/nginx-compress-static.inc:ro
- ./services-conf/nginx-edge-security-headers.inc:/etc/nginx/nginx-edge-security-headers.inc:ro
- ./services-conf/nginx-csp-no-active.inc:/etc/nginx/nginx-csp-no-active.inc:ro
- ./services-conf/nginx-csp-django-html.inc:/etc/nginx/nginx-csp-django-html.inc:ro
- staticfiles_ram:/srv/static:ro
- media_ram:/srv/media:ro
networks:
hpcperfstats_net:
aliases:
- proxy
# Homemade PostgreSQL 18 + TimescaleDB (services-conf/db.Dockerfile). The
# guard1 tag exists only from a build with the data-dir guard in the
# entrypoint (scripts/rebuild_full_site.sh); pull_policy never, so a missing
# tag fails instead of pulling. Role primary: the server writes
# /var/lib/postgresql/hpcperfstats-primary before initdb on an empty bind and
# refuses an existing cluster without it (an unverified PG18 copy). Sites
# that still run PG15 include docker-compose.pg15-primary.yaml, which turns
# this service back into Hub PG15 under the same name
# (docs/how-to/operate/migrate-to-postgresql-18.md).
db:
build:
context: ./services-conf
dockerfile: db.Dockerfile
image: hpcperfstats-db:guard1
pull_policy: never
logging: *hpc-logging
# Default container /dev/shm is 64MiB; Postgres dynamic shared memory exhausts it easily
# under parallel workers. Keep shm_size generous for max_connections=500 + modest parallelism.
#
# Memory / connection budget (operator): max_connections=500 is headroom for many Django
# workers + threads + pipeline pools, not permission to run 500 heavy queries at once.
# Spike control: lower work_mem caps per-query RAM; parallel gather defaults are raised for
# bulk scans (see max_parallel_* below). shared_buffers=64GB on the 377 GiB ingest host:
# the profile showed ~4-5% of Postgres CPU in kernel read/copy from the OS page cache at
# 12GB; db has no mem_limit (see docs/reference/compose-services.md).
#
# statement_timeout / idle_in_transaction_session_timeout: align with Django OPTIONS in settings
# (defaults 120s / 300s in ms). Shed runaway queries; tune bulk jobs if needed.
# max_wal_size / bgwriter / wal_compression: reduce WAL-requested checkpoint churn under ingest.
# docker-compose.pg15-primary.yaml repeats this list for PG15 (minus io_*)
# and for db_pg18; test_pg18_cutover_compose.py keeps the three in parity.
shm_size: "16gb"
command:
- -c
- max_connections=500
- -c
- statement_timeout=120000
- -c
- idle_in_transaction_session_timeout=300000
- -c
- shared_buffers=64GB
- -c
- work_mem=8MB
- -c
- maintenance_work_mem=256MB
- -c
- autovacuum_work_mem=256MB
- -c
- temp_buffers=4MB
- -c
- checkpoint_timeout=30min
- -c
- checkpoint_completion_target=0.9
- -c
- min_wal_size=4GB
# 2026-10: hpcperfstats04 under ingest hit max_wal_size every ~65 s (375 of 390
# checkpoints WAL-requested, 92% of WAL writes forced by a full wal_buffers, 49 backends
# queued on LWLock WALInsert). Larger spacing also cuts full-page-image WAL.
- -c
- max_wal_size=64GB
- -c
- wal_buffers=128MB
# /opt/lz4 WAL compression: pglz made 48 backends queue on LWLock
# WALInsert at ~127 MB/s of WAL (hpcperfstats04, 2026-10).
- -c
- wal_compression=lz4
- -c
- bgwriter_lru_maxpages=800
- -c
- bgwriter_lru_multiplier=5
- -c
- maintenance_io_concurrency=64
- -c
- max_worker_processes=32
- -c
- max_parallel_workers=24
- -c
- max_parallel_workers_per_gather=4
- -c
- max_parallel_maintenance_workers=2
# Ingest replays and occasional DML on compressed host_data chunks can
# exceed TimescaleDB's default 100k tuple decompress cap per transaction.
- -c
- timescaledb.max_tuples_decompressed_per_dml_transaction=1000000
# PG18 asynchronous I/O through a pool of I/O worker processes (the PG18
# default); why no other method: postgres-custom-image-and-migrate-contract.mdc.
- -c
- io_method=worker
- -c
- io_workers=8
# Committed client auth (services-conf/postgres_pg_hba.conf): the Unix socket
# web/pipeline use requires scram-sha-256, like the network; image default
# for local is trust. Overrides $PGDATA/pg_hba.conf on existing data dirs.
- -c
- hba_file=/etc/postgresql/pg_hba.conf
restart: always
healthcheck:
test:
- CMD-SHELL
- pg_isready -U hpcperfstats -d postgres -h 127.0.0.1 -p 5432
interval: 5s
timeout: 3s
retries: 10
stop_signal: SIGINT # Preferred for faster, yet still graceful, shutdowns
stop_grace_period: 30m
# PG18 keeps PGDATA in 18/docker under one mount at /var/lib/postgresql.
# postgres_data_pg18 is declared in the site docker-compose.yaml only.
volumes:
- postgres_data_pg18:/var/lib/postgresql
# unix_socket_directories default; web/pipeline mount the same tmpfs at
# /run/postgresql and connect with [DEFAULT] host = /run/postgresql.
- postgres_runtime:/run/postgresql
- ./services-conf/postgres_pg_hba.conf:/etc/postgresql/pg_hba.conf:ro
environment:
- POSTGRES_USER=hpcperfstats
- POSTGRES_PASSWORD=hpcperfstats
- POSTGRES_DB=hpcperfstats
- TIMESCALEDB_TELEMETRY=off
- HPCPERFSTATS_DB_ROLE=primary
networks:
hpcperfstats_net:
aliases:
- db
rabbitmq:
# Management plugin (HTTP API on 15672) for Admin Monitor stats.
image: docker.io/library/rabbitmq:4.4.1-management-alpine
restart: always
logging: *hpc-logging
hostname: rabbitmq-prod
# Pair with services-conf/rabbitmq_vm_memory.conf (64GiB watermark headroom).
# Without mem_limit, CGROUP_MAX=max and Erlang binary_alloc can OOM the host.
mem_limit: 96g
memswap_limit: 96g
# Skip erl_crash.dump + OS cores on OOM (observed /var/log/rabbitmq/erl_crash.dump).
ulimits:
core: 0
environment:
- RABBITMQ_NODENAME=rabbit@rabbitmq-prod
- RABBITMQ_DEFAULT_USER=guest
- RABBITMQ_DEFAULT_PASS=guest
# Erlang binary/heap carriers: address-order best fit + 512 KiB largest
# mbc (reduces allocator fragmentation under many monitor publishers).
- ERL_FLAGS=+MBas aobf +MBlmbcs 512 +MHlmbcs 512
- RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=+MBas aobf +MBlmbcs 512 +MHlmbcs 512
- ERL_CRASH_DUMP_SECONDS=0
stop_grace_period: 30m
healthcheck:
# `rabbitmq-diagnostics ping` returns non-zero if the node is not ready.
test:
- CMD-SHELL
- rabbitmq-diagnostics -q ping || exit 1
interval: 5s
timeout: 3s
retries: 10
ports:
- "${HPCPERFSTATS_AMQP_PORT:-5672}:5672"
# Management HTTP API / UI — keep compose-internal only (Django uses
# http://rabbitmq:15672). Do not publish 15672 on the host by default;
# uncomment in docker-compose.yaml if needed.
volumes:
- rabbitmq_messages:/var/lib/rabbitmq/
- ./services-conf/rabbitmq_logging.conf:/etc/rabbitmq/conf.d/30-logging_settings.conf:ro
- ./services-conf/rabbitmq_max_message_size.conf:/etc/rabbitmq/conf.d/20-max_message_size.conf:ro
- ./services-conf/rabbitmq_frame_max.conf:/etc/rabbitmq/conf.d/22-frame_max.conf:ro
- ./services-conf/rabbitmq_default_queue_type.conf:/etc/rabbitmq/conf.d/25-default_queue_type.conf:ro
- ./services-conf/rabbitmq_vm_memory.conf:/etc/rabbitmq/conf.d/35-vm_memory.conf:ro
- ./services-conf/rabbitmq_management.conf:/etc/rabbitmq/conf.d/40-management.conf:ro
networks:
hpcperfstats_net:
aliases:
- rabbitmq
volumes:
# Ephemeral Valkey Unix socket dir shared by valkey, web, and pipeline.
# Not a host bind — Docker/Podman named volume only.
valkey_runtime:
driver: local
driver_opts:
type: tmpfs
device: tmpfs
o: size=4m
# Ephemeral PostgreSQL Unix socket dir shared by db, web, and pipeline.
# TCP 5432 stays up on hpcperfstats_net; same-host containers use the socket.
# Not a host bind — Docker/Podman named volume only (like valkey_runtime).
postgres_runtime:
driver: local
driver_opts:
type: tmpfs
device: tmpfs
o: size=4m
# Finished STATIC_ROOT / MEDIA_ROOT copies nginx serves. Disk binds stay
# collectstatic / MEDIA_ROOT staging. Not settings binds (same class as
# valkey_runtime). Podman tmpfs reject → same-redeploy /dev/shm bind.
staticfiles_ram:
driver: local
driver_opts:
type: tmpfs
device: tmpfs
o: size=64m
media_ram:
driver: local
driver_opts:
type: tmpfs
device: tmpfs
o: size=32m
networks:
hpcperfstats_net:
name: ${HPCPERFSTATS_NETWORK_NAME:-hpcperfstats_net}