services: lb: image: haproxy:2.9-alpine ports: - "127.0.0.1:8080:8080" volumes: - ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro depends_on: api: condition: service_healthy healthcheck: test: ["CMD", "haproxy", "-c", "-f", "/usr/local/etc/haproxy/haproxy.cfg"] interval: 10s timeout: 3s retries: 3 deploy: resources: limits: cpus: "0.25" memory: 64M restart: unless-stopped api: build: . expose: - "8080" environment: PORT: "8080" DATABASE_URL: postgres://${PG_USER}:${PG_PASSWORD}@postgres:5432/${PG_DB}?sslmode=disable&timezone=UTC REDIS_URL: redis://redis:6379/0 SESSION_TTL_SECONDS: "${SESSION_TTL_SECONDS:-3600}" IDEMPOTENCY_TTL_SECONDS: "${IDEMPOTENCY_TTL_SECONDS:-86400}" S3_ENDPOINT: "${S3_ENDPOINT:-http://s3:9000}" S3_REGION: "${S3_REGION:-us-east-1}" S3_BUCKET: "${S3_BUCKET:-messenger-attachments}" S3_ACCESS_KEY_ID: "${S3_ACCESS_KEY_ID}" S3_SECRET_ACCESS_KEY: "${S3_SECRET_ACCESS_KEY}" S3_USE_SSL: "${S3_USE_SSL:-false}" MAX_UPLOAD_BYTES: "${MAX_UPLOAD_BYTES:-10485760}" MAX_IMAGE_PIXELS: "${MAX_IMAGE_PIXELS:-40000000}" ATTACHMENT_GRACE_SECONDS: "${ATTACHMENT_GRACE_SECONDS:-600}" depends_on: postgres: condition: service_healthy redis: condition: service_healthy s3: condition: service_started healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/health/ready"] interval: 5s timeout: 3s start_period: 15s retries: 5 deploy: replicas: 2 resources: limits: cpus: "0.50" memory: 512M restart: unless-stopped postgres: image: postgres:16-alpine environment: POSTGRES_USER: ${PG_USER} POSTGRES_PASSWORD: ${PG_PASSWORD} POSTGRES_DB: ${PG_DB} volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ${PG_USER} -d ${PG_DB}"] interval: 5s timeout: 5s retries: 5 deploy: resources: limits: cpus: "0.50" memory: 256M restart: unless-stopped redis: image: redis:7-alpine command: > redis-server --appendonly yes --appendfsync everysec --auto-aof-rewrite-percentage 100 --auto-aof-rewrite-min-size 64mb --maxmemory 128mb --maxmemory-policy noeviction volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 5 deploy: resources: limits: cpus: "0.25" memory: 192M restart: unless-stopped s3: image: rustfs/rustfs@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2 command: ["server", "--address", ":9000"] environment: RUSTFS_ADDRESS: ":9000" RUSTFS_VOLUMES: "/data" RUSTFS_REGION: "${S3_REGION:-us-east-1}" # Root/admin credentials (используются Go-кодом для создания bucket) RUSTFS_ROOT_USER: "${S3_ACCESS_KEY_ID}" RUSTFS_ROOT_PASSWORD: "${S3_SECRET_ACCESS_KEY}" # Console отключена для безопасности RUSTFS_CONSOLE_ENABLE: "false" RUSTFS_OBS_LOGGER_LEVEL: "warn" volumes: - s3_data:/data deploy: resources: limits: cpus: "0.50" memory: 256M restart: unless-stopped volumes: postgres_data: redis_data: s3_data: