services: postgres: image: postgres:17.6-alpine environment: POSTGRES_DB: messenger POSTGRES_USER: messenger POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password secrets: - postgres_password volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"] interval: 5s timeout: 3s retries: 12 start_period: 5s api: build: context: . environment: APP_HOST: 0.0.0.0 APP_PORT: 8080 APP_ENV: lab2 DATABASE_URL_FILE: /run/secrets/database_url CACHE_URL_FILE: /run/secrets/cache_url CACHE_TTL_SECONDS: ${CACHE_TTL_SECONDS:-60} CACHE_STAMPEDE_PROTECTION: ${CACHE_STAMPEDE_PROTECTION:-true} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} secrets: - database_url - cache_url depends_on: postgres: condition: service_healthy redis: condition: service_healthy ports: - "8080:8080" healthcheck: test: ["CMD", "/app/.venv/bin/python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2).read()"] interval: 5s timeout: 3s retries: 12 start_period: 10s redis: image: redis:7.4.2-alpine command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec"] volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 12 start_period: 5s secrets: postgres_password: file: ./secrets/postgres_password database_url: file: ./secrets/database_url cache_url: file: ./secrets/cache_url volumes: postgres_data: redis_data: