name: mtusi-lab2-osokin x-app: &app image: mtusi-messenger:lab2 build: . environment: &app-env APP_HOST: ${APP_HOST:-0.0.0.0} APP_PORT: 8080 APP_ENV: ${APP_ENV:-lab} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} SESSION_STORE: redis DATABASE_URL_FILE: /run/secrets/database_url CACHE_URL_FILE: /run/secrets/cache_url CURSOR_KEY_FILE: /run/secrets/cursor_key secrets: [database_url, cache_url, cursor_key] mem_limit: 512m cpus: 2 dns_opt: ['timeout:1', 'attempts:1'] services: db: image: postgres:17.6-bookworm environment: POSTGRES_DB: messenger POSTGRES_USER: messenger POSTGRES_PASSWORD_FILE: /run/secrets/db_password secrets: [db_password] volumes: [pgdata:/var/lib/postgresql/data] healthcheck: test: [CMD-SHELL, 'pg_isready -U messenger -d messenger'] interval: 2s timeout: 2s retries: 30 mem_limit: 512m cpus: 2 redis: image: redis:7.4.5-bookworm command: [redis-server, /usr/local/etc/redis/redis.conf] volumes: - redisdata:/data - ./infra/redis.conf:/usr/local/etc/redis/redis.conf:ro healthcheck: test: [CMD, redis-cli, ping] interval: 2s timeout: 2s retries: 30 mem_limit: 128m cpus: 1 migrate: <<: *app command: [python, -m, messenger.migrate] healthcheck: {disable: true} depends_on: db: {condition: service_healthy} api: <<: *app ports: ['127.0.0.1:${APP_PORT:-8080}:8080'] depends_on: migrate: {condition: service_completed_successfully} redis: {condition: service_healthy} stop_grace_period: 8s volumes: pgdata: redisdata: secrets: db_password: {file: ./secrets/db_password} database_url: {file: ./secrets/database_url} cache_url: {file: ./secrets/cache_url} cursor_key: {file: ./secrets/cursor_key}