name: vp-lab3 x-api: &api build: . image: vp-lab3-api environment: &app-env DATABASE_URL_FILE: /run/secrets/database_url CACHE_URL: redis://redis:6379/0 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=4)"] interval: 3s timeout: 5s retries: 20 stop_grace_period: 8s mem_limit: 384m cpus: 1 services: api1: <<: *api environment: <<: *app-env INSTANCE_ID: api1 api2: <<: *api environment: <<: *app-env INSTANCE_ID: api2 migrate: build: . image: vp-lab3-api command: [python, -m, src.db] environment: DATABASE_URL_FILE: /run/secrets/database_url secrets: [database_url] depends_on: db: condition: service_healthy mem_limit: 128m cpus: 0.5 lb: image: haproxy:3.0.6-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 mem_limit: 128m cpus: 0.5 db: image: postgres:16.6-bookworm environment: POSTGRES_USER: messenger POSTGRES_DB: messenger POSTGRES_PASSWORD_FILE: /run/secrets/db_password secrets: [db_password] volumes: [pgdata:/var/lib/postgresql/data] healthcheck: test: [CMD-SHELL, "pg_isready -U messenger -d messenger"] interval: 3s timeout: 3s retries: 20 mem_limit: 512m cpus: 1 redis: image: redis:7.4.1-bookworm command: [redis-server, --maxmemory, 64mb, --maxmemory-policy, allkeys-lru, --save, "", --appendonly, "no"] mem_limit: 128m cpus: 0.5 volumes: pgdata: secrets: db_password: file: ./secrets/db_password database_url: file: ./secrets/database_url