services: postgres: image: postgres:16.4 environment: POSTGRES_DB: messenger POSTGRES_USER: messenger POSTGRES_PASSWORD: messenger-local-only volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"] interval: 3s timeout: 3s retries: 20 api1: build: . environment: DATABASE_URL: postgresql://messenger:messenger-local-only@postgres:5432/messenger INSTANCE_ID: api1 SESSION_TTL_SECONDS: 3600 depends_on: postgres: condition: service_healthy healthcheck: test: ["CMD", "python", "-c", "from urllib.request import urlopen; urlopen('http://127.0.0.1:8080/health/ready', timeout=2)"] interval: 3s timeout: 3s retries: 20 api2: build: . environment: DATABASE_URL: postgresql://messenger:messenger-local-only@postgres:5432/messenger INSTANCE_ID: api2 SESSION_TTL_SECONDS: 3600 depends_on: postgres: condition: service_healthy healthcheck: test: ["CMD", "python", "-c", "from urllib.request import urlopen; urlopen('http://127.0.0.1:8080/health/ready', timeout=2)"] interval: 3s timeout: 3s retries: 20 lb: image: nginx:1.27.2-alpine ports: - "8080:80" volumes: - ./infra/nginx.conf:/etc/nginx/nginx.conf:ro depends_on: api1: condition: service_healthy api2: condition: service_healthy volumes: postgres_data: