# Локальный стенд lab4: Клиент → HAProxy → API×N → PostgreSQL + Redis + приватный MinIO. # Публикуется только LB (:8080). Порты API наружу не публикуются. # MinIO API на 127.0.0.1:9000 — только для локальной проверки private bucket; консоль не публикуется. # Запуск: bash scripts/up.sh x-api-env: &api-env APP_HOST: 0.0.0.0 APP_PORT: 8080 APP_ENV: ${APP_ENV:-lab} APP_ACCESS_LOG: ${APP_ACCESS_LOG:-1} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400} DB_MAX_CONNS: ${DB_MAX_CONNS:-5} DATABASE_URL: postgres://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:-messenger}@postgres:5432/${POSTGRES_DB:-messenger}?sslmode=disable REDIS_URL: redis://redis:6379/0 MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760} MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000} S3_ENDPOINT: ${S3_ENDPOINT:-minio:9000} S3_USE_SSL: ${S3_USE_SSL:-0} S3_REGION: ${S3_REGION:-us-east-1} S3_BUCKET: ${S3_BUCKET:-messenger-attachments} S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-app} S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-messenger-app-secret} S3_RECONCILE_GRACE_SECONDS: ${S3_RECONCILE_GRACE_SECONDS:-60} services: postgres: image: postgres:16.6 environment: POSTGRES_USER: ${POSTGRES_USER:-messenger} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-messenger} POSTGRES_DB: ${POSTGRES_DB:-messenger} volumes: - pgdata:/var/lib/postgresql/data ports: - "127.0.0.1:5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-messenger} -d ${POSTGRES_DB:-messenger}"] interval: 5s timeout: 3s retries: 20 stop_grace_period: 10s deploy: resources: limits: cpus: "1.0" memory: 512M redis: image: redis:7.4.1 command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec"] volumes: - redisdata:/data ports: - "127.0.0.1:6379:6379" healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 20 stop_grace_period: 10s deploy: resources: limits: cpus: "0.50" memory: 256M # Публичные minio/minio с Docker Hub сняты (2026). Собираем из community-образа # ghcr.io/coollabsio/minio — бинарь последнего community RELEASE. minio: image: ghcr.io/coollabsio/minio:RELEASE.2025-10-15T17-29-55Z command: ["server", "/data", "--address", ":9000", "--console-address", ":9001"] environment: MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin} MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin-secret} volumes: - miniodata:/data ports: - "127.0.0.1:9000:9000" # Консоль :9001 намеренно не публикуется (уровень 4). # В образе нет curl; TCP-probe + bootstrap ретраит MakeBucket. healthcheck: test: ["CMD", "bash", "-c", "exec 3<>/dev/tcp/127.0.0.1/9000"] interval: 5s timeout: 3s retries: 20 start_period: 10s stop_grace_period: 10s deploy: resources: limits: cpus: "0.50" memory: 512M # Bootstrap без mc: бинарь /s3bootstrap из нашего образа (minio-go + madmin). minio-init: build: . entrypoint: ["/s3bootstrap"] environment: MINIO_ENDPOINT: minio:9000 MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin} MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin-secret} S3_BUCKET: ${S3_BUCKET:-messenger-attachments} S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-app} S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-messenger-app-secret} S3_USE_SSL: ${S3_USE_SSL:-0} depends_on: minio: condition: service_healthy restart: "no" healthcheck: disable: true migrate: build: . command: ["-migrate"] environment: <<: *api-env depends_on: postgres: condition: service_healthy restart: "no" healthcheck: disable: true deploy: resources: limits: cpus: "0.50" memory: 256M api: build: . environment: <<: *api-env expose: - "8080" depends_on: redis: condition: service_healthy postgres: condition: service_healthy minio: condition: service_healthy minio-init: condition: service_completed_successfully healthcheck: test: ["CMD", "/server", "-healthcheck"] interval: 2s timeout: 2s retries: 10 start_period: 15s stop_grace_period: 10s restart: "no" deploy: resources: limits: cpus: ${API_CPUS:-0.50} memory: ${API_MEMORY:-256M} reconcile: build: . entrypoint: ["/reconcile"] environment: <<: *api-env depends_on: postgres: condition: service_healthy minio: condition: service_healthy minio-init: condition: service_completed_successfully restart: "no" deploy: resources: limits: cpus: "0.50" memory: 256M lb: image: haproxy:2.9.14-alpine volumes: - ./infra/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro ports: - "127.0.0.1:8080:8080" depends_on: api: condition: service_healthy healthcheck: test: ["CMD", "haproxy", "-c", "-f", "/usr/local/etc/haproxy/haproxy.cfg"] interval: 10s timeout: 3s retries: 5 start_period: 5s stop_grace_period: 10s deploy: resources: limits: cpus: "0.50" memory: 128M volumes: pgdata: redisdata: miniodata: