x-api: &api build: . image: mtusi-lab3-api:local environment: APP_HOST: 0.0.0.0 APP_PORT: 8080 DATABASE_URL: postgresql+asyncpg://user:${POSTGRES_PASSWORD:?Copy .env.example to .env}@db:5432/messenger CACHE_URL: redis://redis:6379/0 SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} depends_on: migrate: condition: service_completed_successfully redis: condition: service_healthy networks: [front, data] cpus: 0.5 mem_limit: 256m stop_grace_period: 8s services: api1: <<: *api api2: <<: *api migrate: build: . image: mtusi-lab3-api:local command: ["python", "-m", "src.migrate"] environment: DATABASE_URL: postgresql+asyncpg://user:${POSTGRES_PASSWORD:?Copy .env.example to .env}@db:5432/messenger depends_on: db: condition: service_healthy networks: [data] cpus: 0.5 mem_limit: 256m healthcheck: disable: true lb: image: haproxy:3.0.5-alpine ports: ["127.0.0.1:8080:8080"] volumes: - ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro depends_on: api1: condition: service_healthy api2: condition: service_healthy networks: [front] cpus: 0.25 mem_limit: 128m db: image: postgres:16.4-alpine environment: POSTGRES_USER: user POSTGRES_DB: messenger POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Copy .env.example to .env} volumes: [pgdata:/var/lib/postgresql/data] networks: [data] cpus: 1.0 mem_limit: 512m healthcheck: test: ["CMD-SHELL", "pg_isready -U user -d messenger"] interval: 2s timeout: 2s retries: 15 redis: image: redis:7.4.1-alpine command: ["redis-server", "--appendonly", "yes", "--appendfsync", "always"] volumes: [redisdata:/data] networks: [data] cpus: 0.25 mem_limit: 128m healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 2s timeout: 2s retries: 15 networks: front: data: internal: true volumes: pgdata: redisdata: