name: mtusi-lab3-grade3 x-runtime: &runtime image: mtusi-lab3-api:grade3 pull_policy: never environment: &api-env APP_HOST: 0.0.0.0 APP_PORT: 8080 SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} SESSION_STORE: ${SESSION_STORE:-postgres} DATABASE_URL_FILE: /run/secrets/database_url secrets: [database_url] x-api: &api <<: *runtime depends_on: migrate: {condition: service_completed_successfully} postgres: {condition: service_healthy} restart: unless-stopped stop_grace_period: 6s services: postgres: image: postgres:16.8-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 -h 127.0.0.1 -U messenger -d messenger"] interval: 2s timeout: 2s retries: 20 restart: unless-stopped migrate: <<: *runtime build: . command: ["python", "-m", "src.db"] healthcheck: {disable: true} depends_on: postgres: {condition: service_healthy} api1: <<: *api environment: <<: *api-env INSTANCE_ID: api1 api2: <<: *api environment: <<: *api-env INSTANCE_ID: api2 lb: image: haproxy:3.0.11-alpine ports: ["127.0.0.1:${LAB3_PORT:-8080}:8080"] volumes: - ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro restart: unless-stopped tools: profiles: [test] image: mtusi-lab3-tools:grade3 build: {context: ., dockerfile: infra/Dockerfile.tools} volumes: - /var/run/docker.sock:/var/run/docker.sock environment: BASE_URL: http://lb:8080 LAB3_PROJECT: ${COMPOSE_PROJECT_NAME} secrets: postgres_password: {file: ./secrets/postgres_password} database_url: {file: ./secrets/database_url} volumes: postgres_data: