services: postgres: image: postgres:16.4 environment: POSTGRES_USER: messenger POSTGRES_PASSWORD_FILE: /run/secrets/pg_password POSTGRES_DB: messenger secrets: [pg_password] volumes: - pgdata:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"] interval: 3s timeout: 3s retries: 20 api: build: . depends_on: postgres: condition: service_healthy environment: SESSION_TTL_SECONDS: "3600" DATABASE_URL_FILE: /run/secrets/database_url secrets: [database_url] ports: - "8080:8080" healthcheck: test: ["CMD", "python", "-c", "import urllib.request;urllib.request.urlopen('http://localhost:8080/health/ready',timeout=2)"] interval: 3s timeout: 3s retries: 30 secrets: pg_password: file: ./secrets/pg_password.txt database_url: file: ./secrets/database_url.txt volumes: pgdata: