name: lyakhonov-lab4 x-api: &api image: lyakhonov-messenger:lab4 build: . environment: DATABASE_URL_FILE: /run/secrets/database_url CACHE_URL: redis://redis:6379/0 SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} POOL_SIZE: ${POOL_SIZE:-10} S3_ENDPOINT: http://s3:9000 S3_BUCKET: attachments S3_ACCESS_KEY_FILE: /run/secrets/s3_access_key S3_SECRET_KEY_FILE: /run/secrets/s3_secret_key OPTIMIZED_WRITES: ${OPTIMIZED_WRITES:-1} secrets: [database_url, s3_access_key, s3_secret_key] depends_on: migrate: condition: service_completed_successfully cpus: ${API_CPUS:-0.5} mem_limit: ${API_MEMORY:-512m} stop_grace_period: 12s services: db: image: postgres:16.6-alpine environment: POSTGRES_USER: messenger POSTGRES_DB: messenger POSTGRES_PASSWORD_FILE: /run/secrets/db_password secrets: [db_password] volumes: [postgres_data:/var/lib/postgresql/data] healthcheck: test: [CMD-SHELL, "pg_isready -U messenger -d messenger"] interval: 2s timeout: 2s retries: 30 cpus: 1 mem_limit: 512m redis: image: redis:7.4.1-alpine command: [redis-server, --maxmemory, 64mb, --maxmemory-policy, allkeys-lru, --save, "", --appendonly, "no"] cpus: 0.25 mem_limit: 128m migrate: <<: *api command: [python, -m, src.migrate] depends_on: db: condition: service_healthy healthcheck: disable: true s3: image: lyakhonov-storage:lab4 build: context: . dockerfile: Dockerfile.s3 command: [server, /data, --console-address, '127.0.0.1:9001'] environment: MINIO_ROOT_USER_FILE: /run/secrets/s3_root_user MINIO_ROOT_PASSWORD_FILE: /run/secrets/s3_root_password secrets: [s3_root_user, s3_root_password] volumes: [s3_data:/data] cpus: 1 mem_limit: 768m bucket-init: image: lyakhonov-storage:lab4 pull_policy: never cpus: 0.25 mem_limit: 128m entrypoint: [/bin/sh, /bootstrap/bucket.sh] secrets: [s3_root_user, s3_root_password, s3_access_key, s3_secret_key] volumes: [./infra/bucket.sh:/bootstrap/bucket.sh:ro, ./infra/s3-policy.json:/bootstrap/policy.json:ro] depends_on: [s3] api: <<: *api depends_on: migrate: condition: service_completed_successfully bucket-init: condition: service_completed_successfully deploy: replicas: ${API_REPLICAS:-2} reconciler: <<: *api command: [python, -m, src.reconcile, --apply, --interval, '300'] restart: unless-stopped cpus: 0.25 mem_limit: 256m healthcheck: disable: true depends_on: migrate: condition: service_completed_successfully bucket-init: condition: service_completed_successfully lb: image: haproxy:3.0.6-alpine ports: ["127.0.0.1:${LAB4_PORT:-8084}:8080"] volumes: [./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro] depends_on: [api] cpus: 0.5 mem_limit: 128m stop_grace_period: 12s healthcheck: test: [CMD, haproxy, -c, -f, /usr/local/etc/haproxy/haproxy.cfg] interval: 5s timeout: 2s retries: 3 secrets: s3_root_user: file: ./secrets/s3_root_user s3_root_password: file: ./secrets/s3_root_password s3_access_key: file: ./secrets/s3_access_key s3_secret_key: file: ./secrets/s3_secret_key db_password: file: ./secrets/db_password database_url: file: ./secrets/database_url volumes: postgres_data: s3_data: