name: mtusi2026lab3 services: postgres: image: postgres:17.6-bookworm environment: POSTGRES_DB: messenger POSTGRES_USER: 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: 20 migrate: build: . command: ["python", "scripts/migrate.py"] environment: DATABASE_URL_FILE: /run/secrets/database_url secrets: [database_url] depends_on: postgres: condition: service_healthy restart: "no" api: build: . scale: 2 environment: APP_HOST: 0.0.0.0 APP_PORT: 8080 DATABASE_URL_FILE: /run/secrets/database_url SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} secrets: [database_url] depends_on: migrate: condition: service_completed_successfully healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2).close()"] interval: 2s timeout: 3s retries: 20 start_period: 5s stop_grace_period: 10s cpus: 0.5 mem_limit: 256m 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: api: condition: service_healthy cpus: 0.5 mem_limit: 128m secrets: postgres_password: file: ./secrets/postgres_password database_url: file: ./secrets/database_url volumes: postgres_data: