services: api: build: . ports: - "127.0.0.1:${APP_PORT:-8080}:8080" environment: APP_HOST: 0.0.0.0 APP_PORT: 8080 APP_ENV: lab DATABASE_URL: postgresql://messenger:${POSTGRES_PASSWORD:?Run python scripts/init_env.py}@db:5432/messenger CACHE_URL: redis://cache:6379/0 CURSOR_SECRET: ${CURSOR_SECRET:?Run python scripts/init_env.py} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} 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=5)"] interval: 3s timeout: 6s retries: 20 restart: unless-stopped db: image: postgres:17.5-bookworm environment: POSTGRES_DB: messenger POSTGRES_USER: messenger POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Run python scripts/init_env.py} volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"] interval: 2s timeout: 3s retries: 30 restart: unless-stopped cache: image: redis:7.4.4-bookworm command: ["redis-server", "--appendonly", "yes", "--maxmemory", "64mb", "--maxmemory-policy", "allkeys-lru"] volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 2s timeout: 3s retries: 30 restart: unless-stopped volumes: postgres_data: redis_data: