services: db: image: postgres:16.9-bookworm environment: POSTGRES_DB: messenger POSTGRES_USER: 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: 3s retries: 30 cache: image: redis:7.4.3-bookworm command: [redis-server, --appendonly, 'yes', --appendfsync, everysec] volumes: [redis_data:/data] healthcheck: test: [CMD, redis-cli, ping] interval: 2s timeout: 3s retries: 30 api: build: . dns_opt: - "timeout:1" - "attempts:1" environment: DATABASE_URL_FILE: /run/secrets/database_url CACHE_URL: redis://cache:6379/0 SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} DB_POOL_MAX: ${DB_POOL_MAX:-8} secrets: [database_url] ports: ['127.0.0.1:${APP_PORT:-8080}:8080'] depends_on: db: {condition: service_healthy} cache: {condition: service_healthy} healthcheck: test: [CMD, python, -c, "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready', timeout=4)"] interval: 2s timeout: 5s retries: 30 volumes: postgres_data: redis_data: secrets: db_password: file: .secrets/db_password database_url: file: .secrets/database_url