# Локальный стенд лабораторной 4. Секреты только из .env, volumes не удаляются restart-скриптом. # Клиент ходит в haproxy:8080. Реплики api и консоль MinIO наружу не публикуются. name: messenger-lab4 services: postgres: image: postgres:16.10-bookworm environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} command: - postgres - -c - synchronous_commit=on - -c - max_connections=50 volumes: - pgdata:/var/lib/postgresql/data ports: - "127.0.0.1:5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] interval: 5s timeout: 3s retries: 12 start_period: 5s deploy: resources: limits: cpus: "1.00" memory: 512M restart: unless-stopped redis: image: redis:7.4.6-alpine environment: REDIS_PASSWORD: ${REDIS_PASSWORD} command: - sh - -c - exec redis-server --appendonly yes --appendfsync everysec --aof-use-rdb-preamble yes --dir /data --requirepass "$$REDIS_PASSWORD" --bind 0.0.0.0 --protected-mode yes volumes: - redisdata:/data ports: - "127.0.0.1:6379:6379" healthcheck: test: ["CMD-SHELL", "redis-cli --no-auth-warning -a \"$$REDIS_PASSWORD\" ping | grep -q PONG"] interval: 5s timeout: 3s retries: 12 start_period: 3s deploy: resources: limits: cpus: "0.25" memory: 128M restart: unless-stopped minio: # Официальный docker.io/minio/minio на Docker Hub к ноябрю 2026 отдаёт 404. # Это Alpine-сборка того же сервера, тег и digest зафиксированы. image: alpine/minio:RELEASE.2025-10-15T17-29-55Z@sha256:cf23643a6cf9ce159c57643ceb88279e431262282428c9e0bf3a7ef1a97e84b4 # Том создаётся от root. Образ по умолчанию — user minio и не может инициализировать /data. user: "0:0" command: ["server", "/data", "--console-address", "127.0.0.1:9001"] environment: MINIO_ROOT_USER: ${MINIO_ROOT_USER} MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD} volumes: - miniodata:/data ports: - "127.0.0.1:9000:9000" healthcheck: test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:9000/minio/health/live"] interval: 5s timeout: 3s retries: 12 start_period: 5s deploy: resources: limits: cpus: "0.50" memory: 512M restart: unless-stopped minio-init: build: . image: messenger-api:lab4 command: ["bootstrap-s3"] depends_on: minio: condition: service_healthy environment: MINIO_ROOT_USER: ${MINIO_ROOT_USER} MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD} S3_ENDPOINT: http://minio:9000 S3_REGION: ${S3_REGION} S3_BUCKET: ${S3_BUCKET} S3_ACCESS_KEY: ${S3_ACCESS_KEY} S3_SECRET_KEY: ${S3_SECRET_KEY} restart: "no" migrate: build: . image: messenger-api:lab4 command: ["migrate"] depends_on: postgres: condition: service_healthy environment: DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable healthcheck: disable: true deploy: resources: limits: cpus: "0.50" memory: 128M restart: "no" api: build: . image: messenger-api:lab4 depends_on: migrate: condition: service_completed_successfully postgres: condition: service_healthy redis: condition: service_healthy minio-init: condition: service_completed_successfully minio: condition: service_healthy environment: APP_HOST: 0.0.0.0 APP_PORT: "8080" APP_ENV: lab SHUTDOWN_TIMEOUT_SECONDS: ${SHUTDOWN_TIMEOUT_SECONDS:-8} DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable REDIS_URL: redis://:${REDIS_PASSWORD}@redis:6379/0 SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400} DB_MAX_CONNS: ${DB_MAX_CONNS:-8} ARGON2_TIME: ${ARGON2_TIME:-2} ARGON2_MEMORY_KIB: ${ARGON2_MEMORY_KIB:-19456} ARGON2_THREADS: ${ARGON2_THREADS:-1} S3_ENDPOINT: ${S3_ENDPOINT} S3_REGION: ${S3_REGION} S3_BUCKET: ${S3_BUCKET} S3_ACCESS_KEY: ${S3_ACCESS_KEY} S3_SECRET_KEY: ${S3_SECRET_KEY} MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760} MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000} RECONCILE_GRACE_SECONDS: ${RECONCILE_GRACE_SECONDS:-900} expose: - "8080" healthcheck: test: ["CMD", "/messenger", "healthcheck"] interval: 5s timeout: 3s retries: 12 start_period: 10s deploy: replicas: ${API_REPLICAS:-2} resources: limits: cpus: "${API_CPU_LIMIT:-0.50}" memory: ${API_MEM_LIMIT:-384M} restart: unless-stopped haproxy: image: haproxy:2.8.14 depends_on: api: condition: service_healthy volumes: - ./deploy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro ports: - "127.0.0.1:8080:8080" healthcheck: test: ["CMD", "haproxy", "-c", "-f", "/usr/local/etc/haproxy/haproxy.cfg"] interval: 5s timeout: 3s retries: 6 start_period: 3s deploy: resources: limits: cpus: "0.25" memory: 128M restart: unless-stopped volumes: pgdata: redisdata: miniodata: