name: mtusi-lab3 services: postgres: image: postgres:17.2-alpine environment: POSTGRES_USER: messenger POSTGRES_DB: messenger POSTGRES_PASSWORD_FILE: /run/secrets/db_password secrets: - db_password volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: [CMD-SHELL, 'pg_isready -U messenger -d messenger'] interval: 2s timeout: 2s retries: 20 cpus: 1.0 mem_limit: 512m stop_grace_period: 15s migrate: image: mtusi-lab3-api:1.1.0 pull_policy: never command: [python, -m, src.migrate] secrets: - database_url depends_on: postgres: condition: service_healthy cpus: 0.5 mem_limit: 128m api: build: . image: mtusi-lab3-api:1.1.0 environment: SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} DB_POOL_SIZE: ${DB_POOL_SIZE:-1} secrets: - database_url depends_on: migrate: condition: service_completed_successfully deploy: replicas: ${API_REPLICAS:-2} cpus: ${API_CPUS:-0.5} mem_limit: ${API_MEMORY:-256m} stop_grace_period: 8s healthcheck: test: [CMD, python, -S, src/healthcheck.py] interval: 2s timeout: 3s retries: 2 start_period: 10s lb: image: haproxy:3.0.7-alpine ports: - '127.0.0.1:${PUBLIC_PORT:-8080}:8080' volumes: - ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro depends_on: api: condition: service_healthy cpus: 0.5 mem_limit: 128m stop_grace_period: 8s secrets: db_password: file: ./secrets/db_password database_url: file: ./secrets/database_url volumes: postgres_data: