name: mtusi2026lab3 x-api: &api build: . image: mtusi2026lab3-api:local environment: &api-env APP_HOST: 0.0.0.0 APP_PORT: 8080 APP_ENV: ${APP_ENV:-lab} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} DATABASE_URL_FILE: /run/secrets/database_url secrets: [database_url] depends_on: migrate: condition: service_completed_successfully restart: unless-stopped read_only: true cap_drop: [ALL] security_opt: [no-new-privileges:true] stop_grace_period: 7s cpus: 1.0 mem_limit: 256m services: postgres: image: postgres:16.10-bookworm 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: 3s retries: 30 restart: unless-stopped cpus: 1.0 mem_limit: 256m migrate: build: . image: mtusi2026lab3-api:local command: [python, -m, src.database] environment: DATABASE_URL_FILE: /run/secrets/database_url secrets: [database_url] depends_on: postgres: condition: service_healthy restart: "no" healthcheck: disable: true read_only: true cap_drop: [ALL] security_opt: [no-new-privileges:true] cpus: 0.5 mem_limit: 128m api1: <<: *api environment: <<: *api-env INSTANCE_ID: api1 api2: <<: *api environment: <<: *api-env 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:${APP_PORT:-8080}:8080" depends_on: api1: condition: service_healthy api2: condition: service_healthy restart: unless-stopped stop_grace_period: 7s cpus: 0.5 mem_limit: 128m volumes: postgres_data: secrets: postgres_password: file: ./secrets/postgres_password database_url: file: ./secrets/database_url