services: db: cpus: 1.0 mem_limit: 384m image: postgres:17.5-alpine environment: POSTGRES_USER: messenger POSTGRES_DB: messenger POSTGRES_PASSWORD_FILE: /run/secrets/db_password secrets: - db_password volumes: - pgdata:/var/lib/postgresql/data - ./secrets/tls/db:/tls:ro - ./infra/db-entrypoint.sh:/bootstrap.sh:ro - ./infra/pg_hba.conf:/bootstrap/pg_hba.conf:ro healthcheck: test: - CMD-SHELL - pg_isready -U messenger -d messenger interval: 2s timeout: 2s retries: 20 command: - postgres - -c - ssl=on - -c - ssl_cert_file=/tmp/db-tls/cert.pem - -c - ssl_key_file=/tmp/db-tls/key.pem - -c - hba_file=/bootstrap/pg_hba.conf entrypoint: - /bin/sh - /bootstrap.sh cap_drop: - ALL cap_add: - CHOWN - DAC_OVERRIDE - FOWNER - SETUID - SETGID security_opt: - no-new-privileges:true cache: cpus: 0.25 mem_limit: 96m image: redis:7.4.3-alpine command: - redis-server - --bind - 127.0.0.1 - --aclfile - /run/acl/cache.acl volumes: - ./secrets/cache.acl:/run/acl/cache.acl:ro cap_drop: - ALL cap_add: - CHOWN - DAC_OVERRIDE - FOWNER - SETUID - SETGID security_opt: - no-new-privileges:true migrate: image: mtusi-messenger:lab7 cpus: 1.0 mem_limit: 640m env_file: .env environment: CURSOR_KEY_FILE: /run/secrets/cursor_key SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} S3_ENDPOINT: https://s3:9002 APP_HOST: 127.0.0.1 secrets: - database_url - cache_url - cursor_key - broker_url build: . command: - python - src/migrate.py healthcheck: disable: true depends_on: db: condition: service_healthy read_only: true security_opt: &id001 - no-new-privileges:true cap_drop: &id002 - ALL tmpfs: &id003 - /tmp:rw,nosuid,nodev,size=32m volumes: - ./secrets/tls/migrate:/tls:ro s3: image: chrislusf/seaweedfs:3.97 cpus: 1.0 mem_limit: 512m command: - server - -dir=/data - -s3 - -s3.port=9000 - -s3.config=/run/secrets/s3_config - -s3.ip.bind=127.0.0.1 - -ip=127.0.0.1 - -ip.bind=127.0.0.1 secrets: - s3_config volumes: - objects:/data networks: - storage cap_drop: - ALL security_opt: - no-new-privileges:true s3-init: image: mtusi-messenger:lab7 cpus: 1.0 mem_limit: 640m env_file: .env environment: S3_ADMIN_ACCESS_KEY_FILE: /run/secrets/s3_admin_access_key S3_ADMIN_SECRET_KEY_FILE: /run/secrets/s3_admin_secret_key S3_ENDPOINT: https://s3:9002 APP_HOST: 127.0.0.1 secrets: - s3_admin_access_key - s3_admin_secret_key command: - python - src/bootstrap_s3.py healthcheck: disable: true depends_on: s3-tls: condition: service_started read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 volumes: - ./secrets/tls/s3-init:/tls:ro networks: - default - storage broker: image: redis:7.4.3-alpine command: - redis-server - --bind - 127.0.0.1 - --aclfile - /run/acl/broker.acl - --appendonly - 'yes' - --appendfsync - always - --save - '' volumes: - brokerdata:/data - ./secrets/broker.acl:/run/acl/broker.acl:ro mem_limit: 128m cpus: 0.5 cap_drop: - ALL cap_add: - CHOWN - DAC_OVERRIDE - FOWNER - SETUID - SETGID security_opt: - no-new-privileges:true dispatcher: image: mtusi-messenger:lab7 cpus: 1.0 mem_limit: 640m env_file: .env environment: CURSOR_KEY_FILE: /run/secrets/cursor_key CRASH_BEFORE_PUBLISH: ${CRASH_BEFORE_PUBLISH:-0} S3_ENDPOINT: https://s3:9002 APP_HOST: 127.0.0.1 SERVICE_ID: dispatcher secrets: [] command: - python - src/dispatcher.py healthcheck: disable: true depends_on: migrate: condition: service_completed_successfully broker: condition: service_started read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 volumes: - ./secrets/tls/dispatcher:/tls:ro worker: image: mtusi-messenger:lab7 cpus: 1.0 mem_limit: 640m env_file: .env environment: CURSOR_KEY_FILE: /run/secrets/cursor_key CRASH_AFTER_OBJECTS: ${CRASH_AFTER_OBJECTS:-0} S3_ENDPOINT: https://s3:9002 APP_HOST: 127.0.0.1 SERVICE_ID: worker secrets: [] command: - python - src/worker.py healthcheck: disable: true depends_on: s3-init: condition: service_completed_successfully migrate: condition: service_completed_successfully broker: condition: service_started read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 volumes: - ./secrets/tls/worker:/tls:ro networks: - default - storage api-a: image: mtusi-messenger:lab7 cpus: 1.0 mem_limit: 640m env_file: .env environment: CURSOR_KEY_FILE: /run/secrets/cursor_key INSTANCE_ID: api-a S3_ENDPOINT: https://s3:9002 APP_HOST: 127.0.0.1 SERVICE_ID: api-a secrets: [] depends_on: &id004 s3-init: condition: service_completed_successfully migrate: condition: service_completed_successfully cache: condition: service_started stop_grace_period: 8s read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 volumes: - ./secrets/tls/api-a:/tls:ro networks: - default - storage api-b: image: mtusi-messenger:lab7 cpus: 1.0 mem_limit: 640m env_file: .env environment: CURSOR_KEY_FILE: /run/secrets/cursor_key INSTANCE_ID: api-b S3_ENDPOINT: https://s3:9002 APP_HOST: 127.0.0.1 SERVICE_ID: api-b secrets: [] depends_on: *id004 stop_grace_period: 8s read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 volumes: - ./secrets/tls/api-b:/tls:ro networks: - default - storage lb: image: haproxy:3.0.11-alpine cpus: 0.5 mem_limit: 96m ports: - 127.0.0.1:18443:8443 volumes: - ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro - ./secrets/tls/lb:/tls:ro depends_on: api-a: condition: service_healthy api-b: condition: service_healthy security_opt: - no-new-privileges:true cap_drop: - ALL otel-collector: image: otel/opentelemetry-collector-contrib:0.127.0 command: - --config=/etc/otel/config.yaml mem_limit: 192m volumes: - ./infra/otel.yaml:/etc/otel/config.yaml:ro - ./secrets/tls/otel-collector:/tls:ro cpus: 0.5 cap_drop: - ALL security_opt: - no-new-privileges:true prometheus: image: prom/prometheus:v3.4.1 volumes: - ./infra/prometheus.yaml:/etc/prometheus/prometheus.yml:ro - ./infra/alerts.yaml:/etc/prometheus/alerts.yaml:ro - metricsdata:/prometheus - ./secrets/tls/prometheus:/tls:ro mem_limit: 256m command: - --config.file=/etc/prometheus/prometheus.yml - --web.listen-address=127.0.0.1:9090 cpus: 0.5 cap_drop: - ALL security_opt: - no-new-privileges:true loki: image: grafana/loki:3.5.1 command: - -config.file=/etc/loki/config.yaml volumes: - ./infra/loki.yaml:/etc/loki/config.yaml:ro - logsdata:/loki - ./secrets/tls/loki:/tls:ro mem_limit: 256m cpus: 0.5 cap_drop: - ALL security_opt: - no-new-privileges:true tempo: image: grafana/tempo:2.8.0 command: - -config.file=/etc/tempo.yaml volumes: - ./infra/tempo.yaml:/etc/tempo.yaml:ro - tracesdata:/var/tempo - ./secrets/tls/tempo:/tls:ro mem_limit: 256m cpus: 0.5 cap_drop: - ALL security_opt: - no-new-privileges:true grafana: image: grafana/grafana:12.0.2 ports: - 127.0.0.1:13007:3000 volumes: - ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro - grafanadata:/var/lib/grafana - ./infra/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro - ./secrets/grafana-datasources.yaml:/etc/grafana/provisioning/datasources/sources.yaml:ro - ./secrets/grafana_password:/run/grafana_password:ro - ./secrets/tls/grafana:/tls:ro mem_limit: 256m environment: GF_SERVER_PROTOCOL: https GF_SERVER_CERT_FILE: /tls/cert.pem GF_SERVER_CERT_KEY: /tls/key.pem GF_SECURITY_ADMIN_PASSWORD__FILE: /run/grafana_password cpus: 0.5 cap_drop: - ALL security_opt: - no-new-privileges:true api-a-tls: image: mtusi-messenger:lab7 network_mode: service:api-a command: - python - src/tls_bridge.py - /bridge/api-a-tls.json volumes: - ./secrets/tls/api-a:/tls:ro - ./infra/tls:/bridge:ro depends_on: api-a: condition: service_started mem_limit: 96m cpus: 0.25 read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 healthcheck: disable: true api-b-tls: image: mtusi-messenger:lab7 network_mode: service:api-b command: - python - src/tls_bridge.py - /bridge/api-b-tls.json volumes: - ./secrets/tls/api-b:/tls:ro - ./infra/tls:/bridge:ro depends_on: api-b: condition: service_started mem_limit: 96m cpus: 0.25 read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 healthcheck: disable: true broker-tls: image: mtusi-messenger:lab7 network_mode: service:broker command: - python - src/tls_bridge.py - /bridge/broker-tls.json volumes: - ./secrets/tls/broker:/tls:ro - ./infra/tls:/bridge:ro depends_on: broker: condition: service_started mem_limit: 96m cpus: 0.25 read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 healthcheck: disable: true cache-tls: image: mtusi-messenger:lab7 network_mode: service:cache command: - python - src/tls_bridge.py - /bridge/cache-tls.json volumes: - ./secrets/tls/cache:/tls:ro - ./infra/tls:/bridge:ro depends_on: cache: condition: service_started mem_limit: 96m cpus: 0.25 read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 healthcheck: disable: true s3-tls: image: mtusi-messenger:lab7 network_mode: service:s3 command: - python - src/tls_bridge.py - /bridge/s3-tls.json volumes: - ./secrets/tls/s3:/tls:ro - ./infra/tls:/bridge:ro depends_on: s3: condition: service_started mem_limit: 96m cpus: 0.25 read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 healthcheck: disable: true otel-collector-tls-otlp: image: mtusi-messenger:lab7 network_mode: service:otel-collector command: - python - src/tls_bridge.py - /bridge/otel-collector-tls-otlp.json volumes: - ./secrets/tls/otel-collector:/tls:ro - ./infra/tls:/bridge:ro depends_on: otel-collector: condition: service_started mem_limit: 96m cpus: 0.25 read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 healthcheck: disable: true otel-collector-tls-scrape: image: mtusi-messenger:lab7 network_mode: service:otel-collector command: - python - src/tls_bridge.py - /bridge/otel-collector-tls-scrape.json volumes: - ./secrets/tls/otel-collector:/tls:ro - ./infra/tls:/bridge:ro depends_on: otel-collector: condition: service_started mem_limit: 96m cpus: 0.25 read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 healthcheck: disable: true prometheus-tls: image: mtusi-messenger:lab7 network_mode: service:prometheus command: - python - src/tls_bridge.py - /bridge/prometheus-tls.json volumes: - ./secrets/tls/prometheus:/tls:ro - ./infra/tls:/bridge:ro depends_on: prometheus: condition: service_started mem_limit: 96m cpus: 0.25 read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 healthcheck: disable: true loki-tls: image: mtusi-messenger:lab7 network_mode: service:loki command: - python - src/tls_bridge.py - /bridge/loki-tls.json volumes: - ./secrets/tls/loki:/tls:ro - ./infra/tls:/bridge:ro depends_on: loki: condition: service_started mem_limit: 96m cpus: 0.25 read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 healthcheck: disable: true tempo-tls-query: image: mtusi-messenger:lab7 network_mode: service:tempo command: - python - src/tls_bridge.py - /bridge/tempo-tls-query.json volumes: - ./secrets/tls/tempo:/tls:ro - ./infra/tls:/bridge:ro depends_on: tempo: condition: service_started mem_limit: 96m cpus: 0.25 read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 healthcheck: disable: true tempo-tls-otlp: image: mtusi-messenger:lab7 network_mode: service:tempo command: - python - src/tls_bridge.py - /bridge/tempo-tls-otlp.json volumes: - ./secrets/tls/tempo:/tls:ro - ./infra/tls:/bridge:ro depends_on: tempo: condition: service_started mem_limit: 96m cpus: 0.25 read_only: true security_opt: *id001 cap_drop: *id002 tmpfs: *id003 healthcheck: disable: true openbao: image: openbao/openbao:2.3.1 command: - server - -config=/bao/config/openbao.hcl volumes: - ./infra/openbao.hcl:/bao/config/openbao.hcl:ro - ./secrets/tls/openbao:/tls:ro - baodata:/bao/data ports: - 127.0.0.1:18207:8200 mem_limit: 256m cpus: 0.5 environment: SKIP_SETCAP: 'true' security_opt: - no-new-privileges:true cap_drop: - ALL entrypoint: - bao user: 100:1000 depends_on: bao-permissions: condition: service_completed_successfully bao-permissions: image: openbao/openbao:2.3.1 entrypoint: - chown command: - 100:1000 - /bao/data user: 0:0 volumes: - baodata:/bao/data cap_drop: - ALL cap_add: - CHOWN security_opt: - no-new-privileges:true mem_limit: 64m cpus: 0.25 security-check: image: mtusi-messenger:lab7 profiles: - tools entrypoint: - python command: - /checks/check_security.py volumes: - ./student-tests:/checks:ro - ./tests:/tests:ro - ./secrets/tls/operator:/tls:ro - ./secrets/tls:/identities:ro - ./lab.json:/lab.json:ro - ./contracts:/contracts:ro read_only: true tmpfs: - /tmp:size=32m security_opt: - no-new-privileges:true cap_drop: - ALL mem_limit: 256m cpus: 1.0 networks: - default - storage healthcheck: disable: true maintenance: image: mtusi-messenger:lab7 profiles: - tools command: - python - src/cleanup_attachments.py env_file: .env environment: S3_ENDPOINT: https://s3:9002 DATABASE_URL_FILE: /run/secrets/database_url CACHE_URL_FILE: /run/secrets/cache_url CURSOR_KEY_FILE: /run/secrets/cursor_key S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_admin_access_key S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_admin_secret_key secrets: - database_url - cache_url - cursor_key - s3_admin_access_key - s3_admin_secret_key volumes: - ./secrets/tls/operator:/tls:ro networks: - default - storage read_only: true tmpfs: - /tmp:size=32m security_opt: - no-new-privileges:true cap_drop: - ALL mem_limit: 256m cpus: 0.5 healthcheck: disable: true secrets: broker_url: file: ./secrets/broker_url db_password: file: ./secrets/db_password database_url: file: ./secrets/database_url cache_url: file: ./secrets/cache_url cursor_key: file: ./secrets/cursor_key s3_config: file: ./secrets/s3_config s3_admin_access_key: file: ./secrets/s3_admin_access_key s3_admin_secret_key: file: ./secrets/s3_admin_secret_key s3_access_key_id: file: ./secrets/s3_access_key_id s3_secret_access_key: file: ./secrets/s3_secret_access_key volumes: pgdata: null objects: null brokerdata: null metricsdata: null logsdata: null tracesdata: null grafanadata: null baodata: {} networks: default: {} storage: internal: true