name: mtusi-vasilev-lab6 x-application: image: ${API_IMAGE:-mtusi-vasilev:lab6} build: &id001 context: . args: VCS_REF: ${VCS_REF:-uncommitted} environment: &id002 DATABASE_URL_FILE: /run/secrets/database_url CACHE_URL_FILE: /run/secrets/cache_url BROKER_URL_FILE: /run/secrets/broker_url JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5} JOB_LEASE_SECONDS: ${JOB_LEASE_SECONDS:-45} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} S3_ENDPOINT: http://s3:8333 S3_BUCKET: messenger S3_ACCESS_KEY_FILE: /run/secrets/s3_access_key S3_SECRET_KEY_FILE: /run/secrets/s3_secret_key POOL_MAX_SIZE: ${POOL_MAX_SIZE:-8} OTEL_ENABLED: ${OTEL_ENABLED:-1} OTEL_EXPORTER_OTLP_ENDPOINT: http://collector:4318 OTEL_SAMPLE_RATIO: ${OTEL_SAMPLE_RATIO:-1} OTEL_METRIC_INTERVAL_MS: ${OTEL_METRIC_INTERVAL_MS:-5000} secrets: &id006 - database_url - cache_url - broker_url - s3_access_key - s3_secret_key cpus: ${API_CPUS:-0.5} mem_limit: ${API_MEMORY:-512m} pids_limit: 96 read_only: true tmpfs: &id003 - /tmp:size=16m,noexec,nosuid cap_drop: &id004 - ALL security_opt: &id005 - no-new-privileges:true stop_grace_period: 8s services: postgres: image: postgres:17.10-alpine environment: POSTGRES_USER: messenger POSTGRES_DB: messenger POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password secrets: - postgres_password volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: - CMD-SHELL - pg_isready -U messenger -d messenger interval: 2s timeout: 2s retries: 15 cpus: 1 mem_limit: 768m command: - postgres - -c - fsync=on - -c - synchronous_commit=on - -c - full_page_writes=on cache: image: valkey/valkey:8.1.3-alpine command: - valkey-server - --save - '' - --appendonly - 'no' - --maxmemory - 64mb - --maxmemory-policy - allkeys-lru healthcheck: test: - CMD - valkey-cli - ping interval: 2s timeout: 2s retries: 15 cpus: 0.5 mem_limit: 128m broker: image: valkey/valkey:8.1.3-alpine command: - valkey-server - /run/secrets/broker_config secrets: - broker_config - broker_password volumes: - broker_data:/data cpus: 0.5 mem_limit: 192m healthcheck: test: - CMD-SHELL - REDISCLI_AUTH=$$(cat /run/secrets/broker_password) valkey-cli ping interval: 2s timeout: 2s retries: 15 dispatcher: image: ${API_IMAGE:-mtusi-vasilev:lab6} build: *id001 environment: *id002 secrets: - database_url - cache_url - broker_url cpus: 0.25 mem_limit: 192m pids_limit: 96 read_only: true tmpfs: *id003 cap_drop: *id004 security_opt: *id005 stop_grace_period: 8s command: - python - -m - messenger.worker - --dispatcher healthcheck: disable: true depends_on: migrate: condition: service_completed_successfully broker: condition: service_healthy restart: unless-stopped worker: image: ${API_IMAGE:-mtusi-vasilev:lab6} build: *id001 environment: *id002 secrets: *id006 cpus: 1 mem_limit: 896m pids_limit: 96 read_only: true tmpfs: - /tmp:size=32m,noexec,nosuid cap_drop: *id004 security_opt: *id005 stop_grace_period: 30s command: - python - -m - messenger.worker healthcheck: disable: true depends_on: migrate: condition: service_completed_successfully broker: condition: service_healthy s3-bootstrap: condition: service_completed_successfully restart: unless-stopped migrate: image: ${API_IMAGE:-mtusi-vasilev:lab6} build: *id001 environment: *id002 secrets: - database_url cpus: ${API_CPUS:-0.5} mem_limit: ${API_MEMORY:-512m} pids_limit: 96 read_only: true tmpfs: *id003 cap_drop: *id004 security_opt: *id005 stop_grace_period: 8s command: - python - -m - messenger.migrate healthcheck: disable: true depends_on: postgres: condition: service_healthy api: image: ${API_IMAGE:-mtusi-vasilev:lab6} build: *id001 environment: *id002 secrets: - database_url - cache_url - s3_access_key - s3_secret_key cpus: ${API_CPUS:-0.5} mem_limit: ${API_MEMORY:-512m} pids_limit: 96 read_only: true tmpfs: *id003 cap_drop: *id004 security_opt: *id005 stop_grace_period: 8s deploy: replicas: ${API_REPLICAS:-2} depends_on: migrate: condition: service_completed_successfully cache: condition: service_healthy s3-bootstrap: condition: service_completed_successfully storage: image: chrislusf/seaweedfs:4.15@sha256:1593bd2a98964f5d4df83fa7db2b3d4ee7b20190813cc5bf8c3200e0e70d346e command: - server - -dir=/data - -ip=storage - -ip.bind=0.0.0.0 - -filer - -volume.max=32 - -volume.preStopSeconds=0 - -master.volumeSizeLimitMB=64 volumes: - s3_data:/data - ./infra/filer.toml:/etc/seaweedfs/filer.toml:ro networks: - storage_backend cpus: 1 mem_limit: 512m healthcheck: test: - CMD-SHELL - wget -q -O /dev/null http://127.0.0.1:9333/dir/status interval: 2s timeout: 2s retries: 20 s3: image: chrislusf/seaweedfs:4.15@sha256:1593bd2a98964f5d4df83fa7db2b3d4ee7b20190813cc5bf8c3200e0e70d346e command: - s3 - -filer=storage:8888 - -ip.bind=0.0.0.0 - -config=/run/secrets/s3_config - -port=8333 - -port.iceberg=0 secrets: - s3_config networks: - default - storage_backend depends_on: storage: condition: service_healthy cpus: 0.5 mem_limit: 256m s3-bootstrap: image: ${API_IMAGE:-mtusi-vasilev:lab6} build: *id001 environment: S3_ENDPOINT: http://s3:8333 S3_ADMIN_ACCESS_KEY_FILE: /run/secrets/s3_admin_access_key S3_ADMIN_SECRET_KEY_FILE: /run/secrets/s3_admin_secret_key secrets: - s3_admin_access_key - s3_admin_secret_key cpus: ${API_CPUS:-0.5} mem_limit: ${API_MEMORY:-512m} pids_limit: 96 read_only: true tmpfs: *id003 cap_drop: *id004 security_opt: *id005 stop_grace_period: 8s command: - python - -m - messenger.storage_bootstrap healthcheck: disable: true depends_on: s3: condition: service_started lb: image: haproxy:3.2-alpine@sha256:96ec3c75a9264ba94e733eeacb44051ed6e7b79bb77a73c2c36f236b6423f1f0 ports: - 127.0.0.1:${PUBLIC_PORT:-8086}:8080 volumes: - ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro depends_on: api: condition: service_healthy cpus: 0.5 mem_limit: 128m read_only: true tmpfs: - /tmp:size=8m cap_drop: - ALL security_opt: - no-new-privileges:true healthcheck: test: - CMD-SHELL - wget -q -O /dev/null http://127.0.0.1:8080/health/ready interval: 2s timeout: 2s retries: 10 collector: image: otel/opentelemetry-collector-contrib:0.123.0 command: - --config=/etc/otelcol/config.yaml volumes: - ./infra/observability/collector.yaml:/etc/otelcol/config.yaml:ro ports: - 127.0.0.1:14318:4318 - 127.0.0.1:19464:9464 - 127.0.0.1:18888:8888 cpus: 0.5 mem_limit: 256m pids_limit: 96 cap_drop: - ALL security_opt: - no-new-privileges:true prometheus: image: prom/prometheus:v3.2.1 command: - --config.file=/etc/prometheus/prometheus.yml - --storage.tsdb.path=/prometheus - --storage.tsdb.retention.time=24h volumes: - ./infra/observability/prometheus.yaml:/etc/prometheus/prometheus.yml:ro - ./infra/observability/alerts.yaml:/etc/prometheus/alerts.yaml:ro - prometheus_data:/prometheus ports: - 127.0.0.1:19096:9090 cpus: 0.5 mem_limit: 256m loki: image: grafana/loki:3.4.2 command: - -config.file=/etc/loki/config.yaml volumes: - ./infra/observability/loki.yaml:/etc/loki/config.yaml:ro - loki_data:/loki ports: - 127.0.0.1:13106:3100 cpus: 0.5 mem_limit: 384m tempo: image: grafana/tempo:2.7.2 command: - -config.file=/etc/tempo/config.yaml volumes: - ./infra/observability/tempo.yaml:/etc/tempo/config.yaml:ro - tempo_data:/var/tempo ports: - 127.0.0.1:13206:3200 cpus: 0.5 mem_limit: 384m grafana: image: grafana/grafana:11.6.0 environment: GF_AUTH_ANONYMOUS_ENABLED: 'true' GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer GF_AUTH_DISABLE_LOGIN_FORM: 'true' GF_USERS_ALLOW_SIGN_UP: 'false' GF_ANALYTICS_REPORTING_ENABLED: 'false' GF_ANALYTICS_CHECK_FOR_UPDATES: 'false' GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana_password volumes: - ./infra/grafana/provisioning:/etc/grafana/provisioning:ro - ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro - grafana_data:/var/lib/grafana ports: - 127.0.0.1:${GRAFANA_PORT:-13006}:3000 cpus: 0.5 mem_limit: 256m secrets: - grafana_password volumes: postgres_data: null s3_data: null broker_data: null prometheus_data: {} loki_data: {} tempo_data: {} grafana_data: {} networks: storage_backend: internal: true secrets: postgres_password: file: ./secrets/postgres_password database_url: file: ./secrets/database_url cache_url: file: ./secrets/cache_url s3_access_key: file: ./secrets/s3_access_key s3_secret_key: file: ./secrets/s3_secret_key s3_admin_access_key: file: ./secrets/s3_admin_access_key s3_admin_secret_key: file: ./secrets/s3_admin_secret_key s3_config: file: ./secrets/s3_config broker_url: file: ./secrets/broker_url broker_password: file: ./secrets/broker_password broker_config: file: ./secrets/broker_config grafana_password: file: ./secrets/grafana_password