name: chernenko-lab4 x-api: &api build: . image: chernenko-lab4-api:local restart: unless-stopped environment: &api-env DATABASE_URL_FILE: /run/secrets/database_url S3_ENDPOINT: http://s3:9000 S3_BUCKET: messenger-attachments S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_access_key_id S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_secret_access_key SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} MAX_UPLOAD_BYTES: 10485760 MAX_IMAGE_PIXELS: 40000000 secrets: [database_url, s3_access_key_id, s3_secret_access_key] depends_on: migrate: {condition: service_completed_successfully} bootstrap: {condition: service_completed_successfully} mem_limit: 512m cpus: 1 tmpfs: ['/tmp:size=64m,mode=1777'] healthcheck: test: [CMD, python, -c, "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready',timeout=8)"] interval: 3s timeout: 10s retries: 20 services: postgres: image: postgres:17.5-alpine environment: POSTGRES_USER: messenger POSTGRES_DB: messenger POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password secrets: [postgres_password] volumes: [pgdata:/var/lib/postgresql/data] mem_limit: 512m healthcheck: test: [CMD-SHELL, 'pg_isready -U messenger -d messenger'] interval: 2s timeout: 3s retries: 30 s3: build: {context: ., dockerfile: infra/Dockerfile.minio} image: chernenko-lab4-minio:2025.04.22 command: server /data --console-address :9001 environment: MINIO_ROOT_USER_FILE: /run/secrets/minio_root_user MINIO_ROOT_PASSWORD_FILE: /run/secrets/minio_root_password secrets: [minio_root_user, minio_root_password] volumes: [s3data:/data] mem_limit: 512m healthcheck: test: [CMD, curl, -f, http://localhost:9000/minio/health/live] interval: 2s timeout: 3s retries: 30 bootstrap: build: {context: ., dockerfile: infra/Dockerfile.mc} image: chernenko-lab4-mc:2025.04.16 entrypoint: [/bin/sh, /config/bootstrap.sh] secrets: [minio_root_user, minio_root_password, s3_access_key_id, s3_secret_access_key] volumes: ['./infra:/config:ro'] depends_on: s3: {condition: service_healthy} migrate: build: . image: chernenko-lab4-api:local command: python -m src.storage environment: DATABASE_URL_FILE: /run/secrets/database_url secrets: [database_url] depends_on: postgres: {condition: service_healthy} api1: <<: *api environment: <<: *api-env INSTANCE_ID: api1 api2: <<: *api environment: <<: *api-env INSTANCE_ID: api2 lb: image: haproxy:3.0.11-alpine ports: ['127.0.0.1:${HOST_PORT:-8080}:8080'] volumes: ['./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro'] depends_on: api1: {condition: service_healthy} api2: {condition: service_healthy} mem_limit: 64m volumes: pgdata: s3data: secrets: postgres_password: {file: ./secrets/postgres_password} database_url: {file: ./secrets/database_url} minio_root_user: {file: ./secrets/minio_root_user} minio_root_password: {file: ./secrets/minio_root_password} s3_access_key_id: {file: ./secrets/s3_access_key_id} s3_secret_access_key: {file: ./secrets/s3_secret_access_key}