name: mtusi-lab3-maslov services: postgres: image: postgres:18.3@sha256:7e32e9833a6fb1c92c32552794cb6ed569d51b445a54907d35fc112ef39684db environment: POSTGRES_USER: messenger POSTGRES_DB: messenger POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password PGDATA: /var/lib/postgresql/data/pgdata secrets: [postgres_password] volumes: - postgres_data:/var/lib/postgresql healthcheck: test: [CMD-SHELL, 'pg_isready -U messenger -d messenger'] interval: 2s timeout: 2s retries: 20 cpus: 1 mem_limit: 512m memswap_limit: 512m cache: image: valkey/valkey:8.1.3@sha256:fea8b3e67b15729d4bb70589eb03367bab9ad1ee89c876f54327fc7c6e618571 command: [valkey-server, /run/secrets/valkey.conf] secrets: - cache_password - source: valkey_config target: valkey.conf healthcheck: test: [CMD-SHELL, 'REDISCLI_AUTH="$$(cat /run/secrets/cache_password)" valkey-cli ping'] interval: 2s timeout: 2s retries: 20 cpus: 0.25 mem_limit: 128m memswap_limit: 128m migrate: image: ${API_IMAGE:-mtusi-messenger:lab3} pull_policy: never command: [python, -m, src.migrate] environment: DATABASE_URL_FILE: /run/secrets/database_url secrets: [database_url] depends_on: postgres: {condition: service_healthy} cpus: 0.5 mem_limit: 256m read_only: true api: image: ${API_IMAGE:-mtusi-messenger:lab3} build: context: . args: VCS_REF: ${VCS_REF:-unknown} scale: ${API_REPLICAS:-2} environment: APP_HOST: 0.0.0.0 APP_PORT: 8080 DATABASE_URL_FILE: /run/secrets/database_url CACHE_URL_FILE: /run/secrets/cache_url SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} DB_POOL_SIZE: ${DB_POOL_SIZE:-10} secrets: [database_url, cache_url] depends_on: migrate: {condition: service_completed_successfully} cache: {condition: service_healthy} cpus: ${API_CPUS:-0.5} mem_limit: ${API_MEMORY:-384m} memswap_limit: ${API_MEMORY:-384m} pids_limit: 128 read_only: true tmpfs: ["/tmp:rw,noexec,nosuid,size=16m"] cap_drop: [ALL] security_opt: [no-new-privileges:true] stop_grace_period: 10s lb: image: haproxy:3.2.1-alpine@sha256:ac79fe145f2bb6626ff26b584a2d0a34e791906c01015f2ae037aa3137b683d9 ports: - "127.0.0.1:${PUBLIC_PORT:-8083}:8080" volumes: - ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro depends_on: api: {condition: service_healthy} cpus: 0.5 mem_limit: 128m memswap_limit: 128m read_only: true tmpfs: ["/tmp:rw,nosuid,size=4m"] security_opt: [no-new-privileges:true] stop_grace_period: 10s secrets: postgres_password: file: ./secrets/postgres_password database_url: file: ./secrets/database_url cache_password: file: ./secrets/cache_password cache_url: file: ./secrets/cache_url valkey_config: file: ./secrets/valkey.conf name: valkey.conf volumes: postgres_data: