Files
mtusi2026lab7/compose.yaml

1180 lines
32 KiB
YAML

services:
lb:
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
environment:
API_SERVER_MAXCONN: ${API_SERVER_MAXCONN:-64}
volumes:
- ./infra/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- ./secrets/pki/lb:/run/pki:ro
ports:
- 127.0.0.1:${LB_HTTPS_PORT:-18443}:8443
networks:
- edge
- backend
healthcheck:
test:
- CMD
- wget
- -q
- -O
- /dev/null
- http://127.0.0.1:8404/healthz
interval: 2s
timeout: 2s
retries: 3
start_period: 60s
start_interval: 1s
sysctls:
net.ipv4.ip_local_port_range: 10240 65535
net.ipv4.tcp_tw_reuse: '1'
stop_signal: SIGUSR1
stop_grace_period: 8s
restart: unless-stopped
read_only: true
cap_drop:
- ALL
deploy:
resources:
limits:
cpus: ${LB_CPUS:-1}
memory: 128m
security_opt:
- no-new-privileges:true
api:
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
networks: &id001
- backend
build: .
environment:
OTEL_TRACE_RATIO: ${OTEL_TRACE_RATIO:-1}
OTEL_SDK_DISABLED: ${OTEL_SDK_DISABLED:-false}
OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:4318
OTEL_EXPORTER_OTLP_PROTOCOL: ${OTEL_EXPORTER_OTLP_PROTOCOL:-http/protobuf}
OTEL_EXPORTER_OTLP_TIMEOUT: ${OTEL_EXPORTER_OTLP_TIMEOUT:-2}
OTEL_RESOURCE_ATTRIBUTES: ${OTEL_RESOURCE_ATTRIBUTES:-deployment.environment.name=lab}
OTEL_SEMCONV_STABILITY_OPT_IN: http
OTEL_METRIC_EXPORT_INTERVAL: ${OTEL_METRIC_EXPORT_INTERVAL:-10000}
OTEL_BSP_MAX_QUEUE_SIZE: ${OTEL_BSP_MAX_QUEUE_SIZE:-2048}
OTEL_BLRP_MAX_QUEUE_SIZE: ${OTEL_BLRP_MAX_QUEUE_SIZE:-2048}
TELEMETRY_SHUTDOWN_SECONDS: ${TELEMETRY_SHUTDOWN_SECONDS:-2}
S3_ENDPOINT: http://127.0.0.1:19000
S3_REGION: ${S3_REGION:-us-east-1}
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
S3_CONNECT_TIMEOUT_SECONDS: ${S3_CONNECT_TIMEOUT_SECONDS:-1}
S3_READ_TIMEOUT_SECONDS: ${S3_READ_TIMEOUT_SECONDS:-2}
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
IMAGE_CHECK_CONCURRENCY: ${IMAGE_CHECK_CONCURRENCY:-2}
UPLOAD_CONCURRENCY: ${UPLOAD_CONCURRENCY:-3}
UPLOAD_GRACE_SECONDS: ${UPLOAD_GRACE_SECONDS:-900}
UPLOAD_SWEEP_INTERVAL_SECONDS: ${UPLOAD_SWEEP_INTERVAL_SECONDS:-30}
UPLOAD_SWEEP_BATCH: ${UPLOAD_SWEEP_BATCH:-100}
OTEL_SERVICE_NAME: ${OTEL_SERVICE_NAME:-messenger-api}
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400}
COST_EXPERIMENT: ${COST_EXPERIMENT:-false}
WEB_CONCURRENCY: ${WEB_CONCURRENCY:-2}
DB_POOL_MAX_SIZE: ${DB_POOL_MAX_SIZE:-8}
REQUEST_TIMEOUT_SECONDS: ${REQUEST_TIMEOUT_SECONDS:-8}
MIN_TRANSFER_RATE_BYTES: ${MIN_TRANSFER_RATE_BYTES:-131072}
DB_ACQUIRE_TIMEOUT_SECONDS: ${DB_ACQUIRE_TIMEOUT_SECONDS:-1}
DB_COMMAND_TIMEOUT_SECONDS: ${DB_COMMAND_TIMEOUT_SECONDS:-2}
DRAIN_SECONDS: ${DRAIN_SECONDS:-2}
SHUTDOWN_TIMEOUT_SECONDS: ${SHUTDOWN_TIMEOUT_SECONDS:-6}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
MALLOC_MMAP_THRESHOLD_: ${MALLOC_MMAP_THRESHOLD_:-131072}
SERVICE_ROLE: api
BAO_ADDR: https://openbao:8200
PGSSLROOTCERT: /run/pki/ca.crt
NO_PROXY: '*'
HOST: 127.0.0.1
healthcheck:
test:
- CMD
- python
- -c
- import sys,urllib.request;sys.exit(urllib.request.urlopen('http://127.0.0.1:8080/health/ready',timeout=2).status!=200)
interval: 5s
timeout: 3s
retries: 3
start_period: 30s
start_interval: 200ms
stop_grace_period: 8s
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
sysctls:
net.ipv4.tcp_rmem: 4096 65536 262144
net.ipv4.tcp_wmem: 4096 65536 262144
depends_on:
openbao:
condition: service_started
migrate:
condition: service_completed_successfully
s3-init:
condition: service_completed_successfully
deploy:
replicas: ${API_REPLICAS:-2}
resources:
limits:
cpus: ${API_CPUS:-1}
memory: ${API_MEMORY:-512m}
volumes:
- ./secrets/pki/api:/run/pki:ro
- ./infra/security:/etc/security:ro
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
migrate:
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
networks: *id001
pull_policy: never
init: true
command:
- alembic
- upgrade
- head
environment:
LOG_LEVEL: ${LOG_LEVEL:-INFO}
SERVICE_ROLE: migrate
BAO_ADDR: https://openbao:8200
PGSSLROOTCERT: /run/pki/ca.crt
S3_ENDPOINT: http://127.0.0.1:19000
OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:4318
NO_PROXY: '*'
HOST: 127.0.0.1
healthcheck:
disable: true
restart: 'no'
depends_on:
openbao:
condition: service_started
deploy:
resources:
limits:
cpus: '0.5'
memory: 256m
volumes:
- ./secrets/pki/migrate:/run/pki:ro
- ./infra/security:/etc/security:ro
read_only: true
tmpfs:
- /tmp
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
entrypoint:
- python
- /app/secure_runtime.py
postgres:
image: postgres:17.11-alpine@sha256:266d3c257594e195b309ae9d1805e54c788f1d7b375f56bf6c367aac6c917e7b
user: 70:70
command:
- postgres
- -c
- max_connections=${PG_MAX_CONNECTIONS:-200}
- -c
- shared_buffers=${PG_SHARED_BUFFERS:-256MB}
- -c
- shared_preload_libraries=pg_stat_statements
- -c
- pg_stat_statements.track=top
- -c
- track_io_timing=on
- -c
- idle_in_transaction_session_timeout=10s
- -c
- ssl=on
- -c
- ssl_cert_file=/run/pki/tls.crt
- -c
- ssl_key_file=/tmp/server.key
- -c
- hba_file=/etc/pg_hba.conf
environment:
POSTGRES_DB: messenger
POSTGRES_USER: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
secrets:
- postgres_password
volumes:
- pgdata:/var/lib/postgresql/data
- ./secrets/pki/postgres:/run/pki:ro
- ./infra/security/pg_hba.conf:/etc/pg_hba.conf:ro
shm_size: 256m
cpuset: ${PG_CPUSET:-}
healthcheck:
test:
- CMD
- pg_isready
- -h
- 127.0.0.1
- -U
- messenger
- -d
- messenger
interval: 2s
timeout: 3s
retries: 30
start_period: 10s
start_interval: 200ms
stop_grace_period: 10s
restart: unless-stopped
networks:
- backend
deploy:
resources:
limits:
cpus: ${PG_CPUS:-2}
memory: ${PG_MEMORY:-1g}
entrypoint:
- /bin/sh
- -ec
- cp /run/pki/tls.key /tmp/server.key; chmod 600 /tmp/server.key; exec docker-entrypoint.sh
"$@"
- --
tmpfs:
- /tmp
- /var/run/postgresql
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
valkey:
image: valkey/valkey:8.1.11-alpine@sha256:2602ace2be6569bc2bbb06f873776516ab9089821525be34f4305c67eb9db02a
user: 999:1000
command:
- valkey-server
- /run/secrets/valkey.conf
- --appendonly
- 'yes'
- --appendfsync
- always
- --maxmemory
- 64mb
- --maxmemory-policy
- volatile-lru
- --bind
- 127.0.0.1
secrets:
- valkey.conf
volumes:
- valkeydata:/data
healthcheck:
test:
- CMD-SHELL
- REDISCLI_AUTH="$(sed -n "s/^user api on >\([^ ]*\).*/\1/p" /run/secrets/valkey.conf)"
valkey-cli --user api ping | grep -q PONG
interval: 2s
timeout: 3s
retries: 30
stop_grace_period: 10s
restart: unless-stopped
networks:
- backend
deploy:
resources:
limits:
cpus: '0.5'
memory: 128m
s3:
image: rustfs/rustfs:1.0.4@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2
environment:
RUSTFS_ACCESS_KEY_FILE: /run/secrets/s3_root_user
RUSTFS_SECRET_KEY_FILE: /run/secrets/s3_root_password
RUSTFS_ADDRESS: 127.0.0.1:9000
RUSTFS_CONSOLE_ENABLE: 'false'
RUSTFS_REGION: ${S3_REGION:-us-east-1}
RUSTFS_OBS_LOG_DIRECTORY: ''
RUSTFS_OBS_LOGGER_LEVEL: ${S3_LOG_LEVEL:-warn}
secrets:
- s3_root_user
- s3_root_password
volumes:
- s3data:/data
cpuset: ${S3_CPUSET:-}
read_only: true
tmpfs:
- /tmp:size=64m
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
healthcheck:
test:
- CMD
- curl
- -fsS
- -o
- /dev/null
- http://127.0.0.1:9000/health/ready
interval: 2s
timeout: 3s
retries: 30
start_period: 20s
stop_grace_period: 10s
restart: unless-stopped
networks:
- backend
deploy:
resources:
limits:
cpus: ${S3_CPUS:-1}
memory: ${S3_MEMORY:-512m}
reconciler:
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
networks: *id001
pull_policy: never
profiles:
- reconcile
init: true
entrypoint:
- python
- /app/secure_runtime.py
- python
- -m
- messenger.attachments.entrypoints.reconcile
command:
- --dry-run
environment:
S3_ENDPOINT: http://127.0.0.1:19000
S3_REGION: ${S3_REGION:-us-east-1}
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
S3_CONNECT_TIMEOUT_SECONDS: ${S3_CONNECT_TIMEOUT_SECONDS:-1}
S3_READ_TIMEOUT_SECONDS: ${RECONCILE_S3_READ_TIMEOUT_SECONDS:-10}
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
IMAGE_CHECK_CONCURRENCY: ${IMAGE_CHECK_CONCURRENCY:-2}
UPLOAD_CONCURRENCY: ${UPLOAD_CONCURRENCY:-3}
UPLOAD_GRACE_SECONDS: ${UPLOAD_GRACE_SECONDS:-900}
UPLOAD_SWEEP_INTERVAL_SECONDS: ${UPLOAD_SWEEP_INTERVAL_SECONDS:-30}
UPLOAD_SWEEP_BATCH: ${UPLOAD_SWEEP_BATCH:-100}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
SERVICE_ROLE: reconciler
BAO_ADDR: https://openbao:8200
PGSSLROOTCERT: /run/pki/ca.crt
OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:4318
NO_PROXY: '*'
HOST: 127.0.0.1
healthcheck:
disable: true
restart: 'no'
read_only: true
cpuset: ${RECONCILE_CPUSET:-}
depends_on:
openbao:
condition: service_started
deploy:
resources:
limits:
cpus: ${RECONCILE_CPUS:-1}
memory: ${RECONCILE_MEMORY:-256m}
volumes:
- ./secrets/pki/reconciler:/run/pki:ro
- ./infra/security:/etc/security:ro
tmpfs:
- /tmp
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
s3-init:
image: rustfs/rc:v0.1.36@sha256:ab024bfebee49a750ce886b4c70963ccd9ddaa03f491704a90710641d7a26699
read_only: true
tmpfs: &id002
- /tmp:size=16m
environment: &id003
S3_ENDPOINT: http://127.0.0.1:9000
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
RC_CONFIG_DIR: /tmp/rc
SSL_CERT_FILE: /run/pki/ca.crt
user: 65534:65534
volumes: &id004
- ./infra/s3:/s3:ro
- ./secrets/pki/operator:/run/pki:ro
secrets: &id005
- s3_root_user
- s3_root_password
- s3_access_key_id
- s3_secret_access_key
- s3_reconciler_access_key_id
- s3_reconciler_secret_access_key
- s3_worker_access_key_id
- s3_worker_secret_access_key
- s3_relay_access_key_id
- s3_relay_secret_access_key
cap_drop: &id006
- ALL
security_opt: &id007
- no-new-privileges:true
restart: 'no'
deploy: &id008
resources:
limits:
cpus: '0.5'
memory: 64m
entrypoint:
- /bin/sh
- /s3/init.sh
depends_on:
s3-tls:
condition: service_started
network_mode: service:s3
s3-cli:
image: rustfs/rc:v0.1.36@sha256:ab024bfebee49a750ce886b4c70963ccd9ddaa03f491704a90710641d7a26699
read_only: true
tmpfs: *id002
environment: *id003
user: 65534:65534
volumes: *id004
secrets: *id005
cap_drop: *id006
security_opt: *id007
restart: 'no'
deploy: *id008
profiles:
- tools
entrypoint:
- /bin/sh
- /s3/cli.sh
depends_on:
s3-tls:
condition: service_started
network_mode: service:s3
broker:
image: rabbitmq:4.1.8-management-alpine@sha256:54ef5ff505352c1beef05a97ee9bd6ab95b3559a76629ba0119b1d63d8d6e4b2
hostname: broker
user: 100:101
restart: unless-stopped
read_only: true
tmpfs:
- /tmp
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
networks:
- backend
- edge
volumes:
- broker-data:/var/lib/rabbitmq
- ./infra/rabbitmq/rabbitmq.conf:/etc/rabbitmq/conf.d/20-messenger.conf:ro
- ./infra/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins:ro
- ./infra/rabbitmq/definitions.json:/etc/rabbitmq/definitions.d/10-topology.json:ro
secrets:
- source: rabbitmq_users
target: /etc/rabbitmq/definitions.d/20-users.json
- rabbitmq_ops_password
healthcheck:
test:
- CMD
- rabbitmq-diagnostics
- -q
- check_running
interval: 10s
timeout: 10s
retries: 5
start_period: 60s
start_interval: 2s
stop_grace_period: 10s
deploy:
resources:
limits:
cpus: '1'
memory: 512m
environment:
ERL_EPMD_ADDRESS: 127.0.0.1
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: -kernel inet_dist_use_interface {127,0,0,1}
extra_hosts:
- broker:127.0.0.1
relay:
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
pull_policy: never
restart: unless-stopped
init: true
read_only: true
tmpfs:
- /tmp
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
stop_grace_period: 10s
networks: &id009
- backend
healthcheck: &id010
test:
- CMD
- python
- -c
- import os,sys,time;sys.exit(time.time()-os.stat('/tmp/heartbeat').st_mtime>30)
interval: 10s
timeout: 5s
retries: 3
start_period: 30s
start_interval: 2s
depends_on:
openbao:
condition: service_started
migrate:
condition: service_completed_successfully
s3-init:
condition: service_completed_successfully
command:
- python
- -m
- messenger.relay
environment:
OTEL_TRACE_RATIO: ${OTEL_TRACE_RATIO:-1}
OTEL_SDK_DISABLED: ${OTEL_SDK_DISABLED:-false}
OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:4318
OTEL_EXPORTER_OTLP_PROTOCOL: ${OTEL_EXPORTER_OTLP_PROTOCOL:-http/protobuf}
OTEL_EXPORTER_OTLP_TIMEOUT: ${OTEL_EXPORTER_OTLP_TIMEOUT:-2}
OTEL_RESOURCE_ATTRIBUTES: ${OTEL_RESOURCE_ATTRIBUTES:-deployment.environment.name=lab}
OTEL_SEMCONV_STABILITY_OPT_IN: http
OTEL_METRIC_EXPORT_INTERVAL: ${OTEL_METRIC_EXPORT_INTERVAL:-10000}
OTEL_BSP_MAX_QUEUE_SIZE: ${OTEL_BSP_MAX_QUEUE_SIZE:-2048}
OTEL_BLRP_MAX_QUEUE_SIZE: ${OTEL_BLRP_MAX_QUEUE_SIZE:-2048}
TELEMETRY_SHUTDOWN_SECONDS: ${TELEMETRY_SHUTDOWN_SECONDS:-2}
S3_ENDPOINT: http://127.0.0.1:19000
S3_REGION: ${S3_REGION:-us-east-1}
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
S3_CONNECT_TIMEOUT_SECONDS: ${S3_CONNECT_TIMEOUT_SECONDS:-1}
S3_READ_TIMEOUT_SECONDS: ${S3_READ_TIMEOUT_SECONDS:-2}
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
IMAGE_CHECK_CONCURRENCY: ${IMAGE_CHECK_CONCURRENCY:-2}
UPLOAD_CONCURRENCY: ${UPLOAD_CONCURRENCY:-3}
UPLOAD_GRACE_SECONDS: ${UPLOAD_GRACE_SECONDS:-900}
UPLOAD_SWEEP_INTERVAL_SECONDS: ${UPLOAD_SWEEP_INTERVAL_SECONDS:-30}
UPLOAD_SWEEP_BATCH: ${UPLOAD_SWEEP_BATCH:-100}
DB_POOL_MAX_SIZE: ${PIPELINE_DB_POOL_MAX_SIZE:-4}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-60}
JOB_BACKOFF_BASE_SECONDS: ${JOB_BACKOFF_BASE_SECONDS:-2}
STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-86400}
OTEL_SERVICE_NAME: messenger-relay
OUTBOX_POLL_SECONDS: ${OUTBOX_POLL_SECONDS:-1}
SWEEP_INTERVAL_SECONDS: ${SWEEP_INTERVAL_SECONDS:-5}
HEARTBEAT_FILE: /tmp/heartbeat
SERVICE_ROLE: relay
BAO_ADDR: https://openbao:8200
PGSSLROOTCERT: /run/pki/ca.crt
NO_PROXY: '*'
HOST: 127.0.0.1
deploy:
resources:
limits:
cpus: '0.5'
memory: 192m
volumes:
- ./secrets/pki/relay:/run/pki:ro
- ./infra/security:/etc/security:ro
worker:
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
pull_policy: never
restart: unless-stopped
init: true
read_only: true
tmpfs:
- /tmp
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
stop_grace_period: 10s
networks: *id009
healthcheck: *id010
depends_on:
openbao:
condition: service_started
migrate:
condition: service_completed_successfully
s3-init:
condition: service_completed_successfully
command:
- python
- -m
- messenger.worker
environment:
OTEL_TRACE_RATIO: ${OTEL_TRACE_RATIO:-1}
OTEL_SDK_DISABLED: ${OTEL_SDK_DISABLED:-false}
OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:4318
OTEL_EXPORTER_OTLP_PROTOCOL: ${OTEL_EXPORTER_OTLP_PROTOCOL:-http/protobuf}
OTEL_EXPORTER_OTLP_TIMEOUT: ${OTEL_EXPORTER_OTLP_TIMEOUT:-2}
OTEL_RESOURCE_ATTRIBUTES: ${OTEL_RESOURCE_ATTRIBUTES:-deployment.environment.name=lab}
OTEL_SEMCONV_STABILITY_OPT_IN: http
OTEL_METRIC_EXPORT_INTERVAL: ${OTEL_METRIC_EXPORT_INTERVAL:-10000}
OTEL_BSP_MAX_QUEUE_SIZE: ${OTEL_BSP_MAX_QUEUE_SIZE:-2048}
OTEL_BLRP_MAX_QUEUE_SIZE: ${OTEL_BLRP_MAX_QUEUE_SIZE:-2048}
TELEMETRY_SHUTDOWN_SECONDS: ${TELEMETRY_SHUTDOWN_SECONDS:-2}
S3_ENDPOINT: http://127.0.0.1:19000
S3_REGION: ${S3_REGION:-us-east-1}
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
S3_CONNECT_TIMEOUT_SECONDS: ${S3_CONNECT_TIMEOUT_SECONDS:-1}
S3_READ_TIMEOUT_SECONDS: ${S3_READ_TIMEOUT_SECONDS:-2}
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
IMAGE_CHECK_CONCURRENCY: ${IMAGE_CHECK_CONCURRENCY:-2}
UPLOAD_CONCURRENCY: ${UPLOAD_CONCURRENCY:-3}
UPLOAD_GRACE_SECONDS: ${UPLOAD_GRACE_SECONDS:-900}
UPLOAD_SWEEP_INTERVAL_SECONDS: ${UPLOAD_SWEEP_INTERVAL_SECONDS:-30}
UPLOAD_SWEEP_BATCH: ${UPLOAD_SWEEP_BATCH:-100}
DB_POOL_MAX_SIZE: ${PIPELINE_DB_POOL_MAX_SIZE:-4}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-60}
JOB_BACKOFF_BASE_SECONDS: ${JOB_BACKOFF_BASE_SECONDS:-2}
STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-86400}
OTEL_SERVICE_NAME: messenger-worker
WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-2}
RENDER_TIMEOUT_SECONDS: ${RENDER_TIMEOUT_SECONDS:-30}
RENDER_MEMORY_MB: ${RENDER_MEMORY_MB:-448}
RENDER_TASKS_PER_CHILD: ${RENDER_TASKS_PER_CHILD:-100}
HEARTBEAT_FILE: /tmp/heartbeat
SERVICE_ROLE: worker
BAO_ADDR: https://openbao:8200
PGSSLROOTCERT: /run/pki/ca.crt
NO_PROXY: '*'
HOST: 127.0.0.1
deploy:
resources:
limits:
cpus: ${WORKER_CPUS:-2}
memory: ${WORKER_MEMORY:-1g}
volumes:
- ./secrets/pki/worker:/run/pki:ro
- ./infra/security:/etc/security:ro
healthtools:
image: busybox:1.37.0-musl@sha256:5cec3fc171c87218698e85a52af7087de727372aae264a787b8112901a5b0092
command:
- cp
- /bin/busybox
- /hc/busybox
restart: 'no'
network_mode: none
volumes:
- healthtools:/hc
logging: &id011
driver: json-file
options:
max-size: 10m
max-file: '3'
otel-collector:
restart: unless-stopped
stop_grace_period: 10s
cap_drop: &id012
- ALL
security_opt: &id013
- no-new-privileges:true
logging: *id011
image: otel/opentelemetry-collector-contrib:0.163.2@sha256:7f22d2a6748110ffb6a59bc0df448bccbf501cdb667d610ede4c61d3863d5849
command:
- --config=/etc/otelcol/${OTEL_COLLECTOR_CONFIG:-collector.yaml}
networks:
- backend
- edge
environment:
GOMEMLIMIT: 300MiB
volumes:
- ./infra/otel:/etc/otelcol:ro
- healthtools:/hc:ro
- ./secrets/pki/otel-collector:/run/pki:ro
depends_on:
healthtools:
condition: service_completed_successfully
healthcheck:
test:
- CMD
- /hc/busybox
- wget
- -q
- -O
- /dev/null
- http://127.0.0.1:13133/
interval: 10s
timeout: 3s
retries: 6
start_period: 10s
start_interval: 2s
deploy:
resources:
limits:
cpus: '0.50'
memory: 384M
prometheus:
restart: unless-stopped
stop_grace_period: 10s
cap_drop: *id012
security_opt: *id013
logging: *id011
image: prom/prometheus:v3.15.1@sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --storage.tsdb.retention.time=${PROMETHEUS_RETENTION:-7d}
- --storage.tsdb.retention.size=1GB
- --web.enable-otlp-receiver
- --enable-feature=exemplar-storage
- --web.listen-address=127.0.0.1:9090
networks:
- backend
- edge
volumes:
- ./infra/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./infra/prometheus/rules:/etc/prometheus/rules:ro
- prometheus-data:/prometheus
- ./secrets/pki/prometheus:/run/pki:ro
healthcheck:
test:
- CMD
- wget
- -q
- -O
- /dev/null
- http://127.0.0.1:9090/-/ready
interval: 10s
timeout: 3s
retries: 6
start_period: 15s
start_interval: 2s
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
loki:
restart: unless-stopped
stop_grace_period: 10s
cap_drop: *id012
security_opt: *id013
logging: *id011
image: grafana/loki:3.7.9@sha256:0db216b630ae1f348a1584c67f3cead8b4c1fc839169a39501db664744158e28
command:
- -config.file=/etc/loki/loki.yaml
networks:
- edge
environment:
GOMEMLIMIT: 300MiB
volumes:
- ./infra/loki/loki.yaml:/etc/loki/loki.yaml:ro
- loki-data:/loki
- healthtools:/hc:ro
depends_on:
healthtools:
condition: service_completed_successfully
healthcheck:
test:
- CMD
- /hc/busybox
- wget
- -q
- -O
- /dev/null
- http://127.0.0.1:3100/ready
interval: 10s
timeout: 3s
retries: 10
start_period: 30s
start_interval: 2s
deploy:
resources:
limits:
cpus: '0.50'
memory: 384M
tempo:
restart: unless-stopped
stop_grace_period: 10s
cap_drop: *id012
security_opt: *id013
logging: *id011
image: grafana/tempo:2.10.10@sha256:12b0820f13ffa10ce956b6e9acc3b03f3cffded99109be6cc09d106fe56e5d38
command:
- -config.file=/etc/tempo/tempo.yaml
networks:
- edge
environment:
GOMEMLIMIT: 300MiB
volumes:
- ./infra/tempo/tempo.yaml:/etc/tempo/tempo.yaml:ro
- tempo-data:/var/tempo
- healthtools:/hc:ro
depends_on:
healthtools:
condition: service_completed_successfully
healthcheck:
test:
- CMD
- /hc/busybox
- wget
- -q
- -O
- /dev/null
- http://127.0.0.1:3200/ready
interval: 10s
timeout: 3s
retries: 10
start_period: 30s
start_interval: 2s
deploy:
resources:
limits:
cpus: '0.50'
memory: 384M
grafana:
restart: unless-stopped
stop_grace_period: 10s
cap_drop: *id012
security_opt: *id013
logging: *id011
image: grafana/grafana:12.4.14@sha256:ae509d9ae8c1021ca32ec370a9ca975d40165eda9fccd1e1102d317ff8787cd7
networks:
- edge
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana_admin_password
GF_USERS_ALLOW_SIGN_UP: 'false'
GF_AUTH_ANONYMOUS_ENABLED: 'false'
GF_ANALYTICS_REPORTING_ENABLED: 'false'
GF_ANALYTICS_CHECK_FOR_UPDATES: 'false'
GF_ANALYTICS_CHECK_FOR_PLUGIN_UPDATES: 'false'
GF_NEWS_NEWS_FEED_ENABLED: 'false'
GF_PLUGINS_PREINSTALL_DISABLED: 'true'
GF_LOG_LEVEL: warn
GF_SERVER_HTTP_ADDR: 127.0.0.1
secrets:
- grafana_admin_password
volumes:
- ./infra/grafana/provisioning:/etc/grafana/provisioning:ro
- ./infra/grafana/dashboards:/etc/grafana/dashboards:ro
- grafana-data:/var/lib/grafana
depends_on:
prometheus:
condition: service_started
loki:
condition: service_started
tempo:
condition: service_started
healthcheck:
test:
- CMD
- curl
- -fsS
- -o
- /dev/null
- http://127.0.0.1:3000/api/health
interval: 10s
timeout: 3s
retries: 10
start_period: 30s
start_interval: 2s
deploy:
resources:
limits:
cpus: '0.50'
memory: 384M
ports:
- 127.0.0.1:${GRAFANA_HTTPS_PORT:-27300}:9443
s3-tls:
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
network_mode: service:s3
volumes:
- ./infra/security/s3.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- ./secrets/pki/s3:/run/pki:ro
depends_on:
s3:
condition: service_started
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.25'
memory: 64m
valkey-tls:
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
network_mode: service:valkey
volumes:
- ./infra/security/valkey.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- ./secrets/pki/valkey:/run/pki:ro
depends_on:
valkey:
condition: service_started
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.25'
memory: 64m
broker-tls:
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
network_mode: service:broker
volumes:
- ./infra/security/broker.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- ./secrets/pki/broker:/run/pki:ro
depends_on:
broker:
condition: service_started
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.25'
memory: 64m
otel-collector-tls:
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
network_mode: service:otel-collector
volumes:
- ./infra/security/otel-collector.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- ./secrets/pki/otel-collector:/run/pki:ro
depends_on:
otel-collector:
condition: service_started
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.25'
memory: 64m
prometheus-tls:
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
network_mode: service:prometheus
volumes:
- ./infra/security/prometheus.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- ./secrets/pki/prometheus:/run/pki:ro
depends_on:
prometheus:
condition: service_started
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.25'
memory: 64m
loki-tls:
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
network_mode: service:loki
volumes:
- ./infra/security/loki.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- ./secrets/pki/loki:/run/pki:ro
depends_on:
loki:
condition: service_started
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.25'
memory: 64m
tempo-tls:
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
network_mode: service:tempo
volumes:
- ./infra/security/tempo.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- ./secrets/pki/tempo:/run/pki:ro
depends_on:
tempo:
condition: service_started
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.25'
memory: 64m
grafana-tls:
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
network_mode: service:grafana
volumes:
- ./infra/security/grafana.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- ./secrets/pki/grafana:/run/pki:ro
depends_on:
grafana:
condition: service_started
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.25'
memory: 64m
openbao:
image: openbao/openbao:2.7.2@sha256:5046911075e137e154ce49ab051502f4ec7cf367d484ae4a4dce665d9b90561f
entrypoint:
- bao
command:
- server
- -config=/etc/bao/server.hcl
user: 100:1000
read_only: true
tmpfs:
- /tmp
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
networks:
- backend
- edge
ports:
- 127.0.0.1:${BAO_HTTPS_PORT:-28200}:8200
volumes:
- bao-data:/bao/data
- ./infra/openbao/server.hcl:/etc/bao/server.hcl:ro
- ./secrets/pki/openbao:/run/pki:ro
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.5'
memory: 256m
depends_on:
bao-init:
condition: service_completed_successfully
bao-init:
image: busybox:1.37.0-musl@sha256:5cec3fc171c87218698e85a52af7087de727372aae264a787b8112901a5b0092
command:
- chown
- 100:1000
- /data
user: 0:0
network_mode: none
volumes:
- bao-data:/data
cap_drop:
- ALL
cap_add:
- CHOWN
security_opt:
- no-new-privileges:true
read_only: true
restart: 'no'
deploy:
resources:
limits:
cpus: '0.1'
memory: 16m
security-audit:
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
profiles:
- audit
entrypoint:
- python
- /audit/security_probe.py
networks:
- backend
- edge
volumes:
- ./scripts:/audit:ro
- ./secrets/pki:/audit-pki:ro
read_only: true
tmpfs:
- /tmp
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
deploy:
resources:
limits:
cpus: '1'
memory: 256m
secrets:
postgres_password:
file: ./secrets/postgres_password
database_url:
file: ./secrets/database_url
valkey.conf:
file: ./secrets/valkey.conf
cache_url:
file: ./secrets/cache_url
cursor_secret:
file: ./secrets/cursor_secret
s3_root_user:
file: ./secrets/s3_root_user
s3_root_password:
file: ./secrets/s3_root_password
s3_access_key_id:
file: ./secrets/s3_access_key_id
s3_secret_access_key:
file: ./secrets/s3_secret_access_key
s3_worker_access_key_id:
file: ./secrets/s3_worker_access_key_id
s3_worker_secret_access_key:
file: ./secrets/s3_worker_secret_access_key
rabbitmq_users:
file: ./secrets/rabbitmq_users.json
rabbitmq_ops_password:
file: ./secrets/rabbitmq_ops_password
broker_url_api:
file: ./secrets/broker_url_api
broker_url_worker:
file: ./secrets/broker_url_worker
grafana_admin_password:
file: ./secrets/grafana_admin_password
s3_reconciler_access_key_id:
file: ./secrets/s3_reconciler_access_key_id
s3_reconciler_secret_access_key:
file: ./secrets/s3_reconciler_secret_access_key
s3_relay_access_key_id:
file: ./secrets/s3_relay_access_key_id
s3_relay_secret_access_key:
file: ./secrets/s3_relay_secret_access_key
volumes:
pgdata: null
valkeydata: null
s3data: null
broker-data: null
healthtools: null
prometheus-data: null
loki-data: null
tempo-data: null
grafana-data: null
bao-data: null
networks:
edge: null
backend:
internal: true
name: mtusi2026lab7