services: db: image: postgres:16.6-bookworm environment: POSTGRES_DB: messenger POSTGRES_USER: messenger POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password secrets: - postgres_password volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"] interval: 2s timeout: 3s retries: 30 api: build: . environment: APP_HOST: ${APP_HOST:-0.0.0.0} APP_PORT: ${APP_PORT:-8080} APP_ENV: ${APP_ENV:-lab} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} SESSION_STORE: postgres DATABASE_URL_FILE: /run/secrets/database_url ports: - "127.0.0.1:8080:${APP_PORT:-8080}" secrets: - database_url depends_on: db: condition: service_healthy healthcheck: test: ["CMD", "python", "-c", "import os, urllib.request; urllib.request.urlopen('http://127.0.0.1:'+os.getenv('APP_PORT','8080')+'/health/ready',timeout=3)"] interval: 3s timeout: 5s retries: 20 volumes: postgres_data: secrets: postgres_password: file: ./secrets/postgres_password database_url: file: ./secrets/database_url