services: postgres: image: postgres:16.2-alpine environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} volumes: - pgdata:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] interval: 5s timeout: 5s retries: 10 ports: - "127.0.0.1:5432:5432" redis: image: redis:7.2-alpine command: ["redis-server", "--appendonly", "yes"] volumes: - redisdata:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 5s retries: 10 ports: - "127.0.0.1:6379:6379" api: build: . ports: - "127.0.0.1:8080:8080" env_file: .env depends_on: postgres: condition: service_healthy redis: condition: service_healthy healthcheck: test: - "CMD" - "python" - "-c" - "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2).status==200 else 1)" interval: 10s timeout: 5s retries: 10 start_period: 20s volumes: pgdata: redisdata: