services: postgres: image: postgres:17.4-alpine environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] interval: 5s timeout: 3s retries: 20 redis: image: redis:7.4.2-alpine command: ["redis-server", "--appendonly", "yes", "--appendfsync", "always"] volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 20 migrate: build: . command: ["alembic", "upgrade", "head"] environment: DATABASE_URL: ${DATABASE_URL} REDIS_URL: ${REDIS_URL} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS} depends_on: postgres: condition: service_healthy restart: "no" api: build: . environment: DATABASE_URL: ${DATABASE_URL} REDIS_URL: ${REDIS_URL} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS} LOG_LEVEL: ${LOG_LEVEL:-info} ports: - "${APP_PORT:-8080}:8080" depends_on: migrate: condition: service_completed_successfully redis: condition: service_healthy healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=3).read()"] interval: 10s timeout: 3s retries: 10 volumes: postgres_data: redis_data: