name: mtusi-lab5 x-app: &app image: mtusi-messenger:lab5 build: . init: true restart: unless-stopped read_only: true tmpfs: ["/tmp:size=67108864,mode=1777"] mem_limit: 1g cpus: 1.0 environment: &environment DATABASE_URL_FILE: /run/secrets/database_url S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_access_key_id S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_secret_access_key CURSOR_SECRET_FILE: /run/secrets/cursor_secret BROKER_URL_FILE: /run/secrets/broker_url S3_ENDPOINT: http://s3:9000 S3_BUCKET: messenger-attachments SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} MAX_UPLOAD_BYTES: 10485760 MAX_IMAGE_PIXELS: 40000000 MAX_PENDING_JOBS: ${MAX_PENDING_JOBS:-1000} WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-2} JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5} JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-60} JOB_LEASE_SECONDS: ${JOB_LEASE_SECONDS:-90} STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-86400} secrets: [database_url, s3_access_key_id, s3_secret_access_key, cursor_secret, broker_url] networks: [private] depends_on: migrate: {condition: service_completed_successfully} bootstrap: {condition: service_completed_successfully} healthcheck: test: [CMD, python, -c, "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready',timeout=5)"] interval: 5s timeout: 6s retries: 15 services: postgres: image: postgres:17.6-alpine3.22 environment: POSTGRES_DB: messenger POSTGRES_USER: messenger POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password secrets: [postgres_password] volumes: [postgres-data:/var/lib/postgresql/data] networks: [private] mem_limit: 384m cpus: 1.0 restart: unless-stopped healthcheck: test: [CMD-SHELL, "pg_isready -U messenger -d messenger"] interval: 3s timeout: 3s retries: 20 s3: image: mtusi-minio:RELEASE.2025-04-22T22-12-26Z build: {context: ., dockerfile: infra/Dockerfile.minio, target: server} entrypoint: [/bin/sh, /config/minio-start.sh] secrets: [minio_root_user, minio_root_password] volumes: [s3-data:/data, ./infra/minio-start.sh:/config/minio-start.sh:ro] networks: [private] mem_limit: 512m cpus: 1.0 restart: unless-stopped healthcheck: test: [CMD, python, -c, "import urllib.request; urllib.request.urlopen('http://localhost:9000/minio/health/ready',timeout=2)"] interval: 3s timeout: 3s retries: 30 bootstrap: image: mtusi-mc:RELEASE.2025-04-16T18-13-26Z build: {context: ., dockerfile: infra/Dockerfile.minio, target: client} entrypoint: [/bin/sh, /config/bootstrap.sh] secrets: [minio_root_user, minio_root_password, s3_access_key_id, s3_secret_access_key, worker_access_key_id, worker_secret_access_key, operator_access_key_id, operator_secret_access_key] volumes: [./infra:/config:ro] networks: [private] depends_on: {s3: {condition: service_healthy}} broker: image: redis:7.4.5-alpine3.21 user: redis entrypoint: [/bin/sh, /config/broker-start.sh] secrets: [broker_password] volumes: [broker-data:/data, ./infra/broker-start.sh:/config/broker-start.sh:ro] tmpfs: ["/tmp:size=1048576,mode=1777"] networks: [private] mem_limit: 256m cpus: 0.5 restart: unless-stopped healthcheck: test: [CMD-SHELL, 'REDISCLI_AUTH=$$(cat /run/secrets/broker_password) redis-cli ping | grep -q PONG'] interval: 3s timeout: 3s retries: 20 migrate: <<: *app restart: "no" command: [python, -m, scripts.migrate] depends_on: {postgres: {condition: service_healthy}} healthcheck: {disable: true} api1: <<: *app environment: {<<: *environment, INSTANCE_ID: api1} api2: <<: *app environment: {<<: *environment, INSTANCE_ID: api2} lb: image: haproxy:3.0.11-alpine volumes: [./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro] ports: ["127.0.0.1:${LAB5_PORT:-8085}:8080"] networks: [private, edge] mem_limit: 128m cpus: 0.5 restart: unless-stopped depends_on: {api1: {condition: service_healthy}, api2: {condition: service_healthy}} publisher: <<: *app command: [python, -m, src.publisher] healthcheck: {disable: true} worker: <<: *app command: [python, -m, src.worker] mem_limit: 2g cpus: 2.0 tmpfs: ["/tmp:size=134217728,mode=1777"] healthcheck: {disable: true} environment: <<: *environment S3_ACCESS_KEY_ID_FILE: /run/secrets/worker_access_key_id S3_SECRET_ACCESS_KEY_FILE: /run/secrets/worker_secret_access_key secrets: [database_url, worker_access_key_id, worker_secret_access_key, broker_url] janitor: <<: *app command: [python, -m, src.cleanup] healthcheck: {disable: true} environment: &operator-environment <<: *environment S3_ACCESS_KEY_ID_FILE: /run/secrets/operator_access_key_id S3_SECRET_ACCESS_KEY_FILE: /run/secrets/operator_secret_access_key secrets: &operator-secrets [database_url, operator_access_key_id, operator_secret_access_key, broker_url] operator: <<: *app restart: "no" profiles: [tools] command: [python, -m, src.operator, failed] healthcheck: {disable: true} environment: *operator-environment secrets: *operator-secrets test-runner: <<: *app restart: "no" profiles: [tests] command: [python, student-tests/pipeline.py, acceptance] healthcheck: {disable: true} environment: <<: *operator-environment ENABLE_FAULTS: "1" BASE_URL: http://lb:8080 secrets: [database_url, operator_access_key_id, operator_secret_access_key, broker_url, s3_access_key_id, s3_secret_access_key] volumes: [./evidence:/evidence] networks: private: {internal: true} edge: {} volumes: postgres-data: s3-data: broker-data: secrets: postgres_password: {file: ./secrets/postgres_password} database_url: {file: ./secrets/database_url} minio_root_user: {file: ./secrets/minio_root_user} minio_root_password: {file: ./secrets/minio_root_password} s3_access_key_id: {file: ./secrets/s3_access_key_id} s3_secret_access_key: {file: ./secrets/s3_secret_access_key} worker_access_key_id: {file: ./secrets/worker_access_key_id} worker_secret_access_key: {file: ./secrets/worker_secret_access_key} operator_access_key_id: {file: ./secrets/operator_access_key_id} operator_secret_access_key: {file: ./secrets/operator_secret_access_key} cursor_secret: {file: ./secrets/cursor_secret} broker_password: {file: ./secrets/broker_password} broker_url: {file: ./secrets/broker_url}