name: mtusi-lab4 x-s3-env: &s3-env S3_ENDPOINT: http://s3:9000 S3_REGION: us-east-1 S3_BUCKET: messenger-attachments S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_access_key_id S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_secret_access_key x-api: &api image: mtusi-messenger:lab4 build: . environment: <<: *s3-env APP_HOST: 0.0.0.0 APP_PORT: 8080 SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400} DATABASE_URL_FILE: /run/secrets/database_url secrets: [database_url, s3_access_key_id, s3_secret_access_key] depends_on: migrate: condition: service_completed_successfully s3-init: condition: service_completed_successfully healthcheck: test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:8080/health/ready').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"] interval: 2s timeout: 4s retries: 20 stop_grace_period: 10s services: db: image: postgres:17.6-alpine environment: POSTGRES_DB: messenger POSTGRES_USER: messenger POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password secrets: [postgres_password] volumes: [pgdata:/var/lib/postgresql/data] healthcheck: test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"] interval: 2s timeout: 3s retries: 30 migrate: image: mtusi-messenger:lab4 build: . command: ["node", "src/migrate.js"] environment: DATABASE_URL_FILE: /run/secrets/database_url secrets: [database_url] depends_on: db: condition: service_healthy restart: "no" s3: image: mtusi-minio:RELEASE.2025-04-22T22-12-26Z build: context: . dockerfile: infra/Dockerfile.s3 command: ["server", "/data", "--console-address", ":9001"] environment: MINIO_ROOT_USER_FILE: /run/secrets/s3_access_key_id MINIO_ROOT_PASSWORD_FILE: /run/secrets/s3_secret_access_key secrets: [s3_access_key_id, s3_secret_access_key] volumes: [s3data:/data] healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 2s timeout: 3s retries: 30 s3-init: image: mtusi-messenger:lab4 build: . command: ["node", "src/storage.js"] environment: <<: *s3-env secrets: [s3_access_key_id, s3_secret_access_key] depends_on: s3: condition: service_healthy restart: "no" api1: <<: *api api2: <<: *api lb: image: haproxy:3.0.12-alpine ports: ["127.0.0.1:${APP_PORT:-8084}:8080"] volumes: [./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro] depends_on: api1: condition: service_healthy api2: condition: service_healthy volumes: pgdata: s3data: secrets: postgres_password: file: ./secrets/postgres_password database_url: file: ./secrets/database_url s3_access_key_id: file: ./secrets/s3_access_key_id s3_secret_access_key: file: ./secrets/s3_secret_access_key