services: db: image: postgres:16-alpine environment: POSTGRES_DB: messenger POSTGRES_USER: postgres POSTGRES_PASSWORD: secret ports: - "5432:5432" volumes: - pgdata:/var/lib/postgresql/data - ./migrations:/docker-entrypoint-initdb.d healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres -d messenger"] interval: 5s retries: 5 redis: image: valkey/valkey:7-alpine volumes: - redisdata:/data # --- RustFS S3 --- rustfs: image: rustfs/rustfs:latest environment: - RUSTFS_ACCESS_KEY=rustfsadmin - RUSTFS_SECRET_KEY=rustfssecret - RUSTFS_CONSOLE_ENABLE=true volumes: - rustfsdata:/data ports: - "9000:9000" # S3 API - "9001:9001" # Консоль # Правильный синтаксис: путь к данным передаётся в конце command: /data healthcheck: # Правильный эндпоинт: /health test: ["CMD-SHELL", "curl -f http://localhost:9000/health || exit 1"] interval: 10s timeout: 5s retries: 5 start_period: 30s # Инициализация: создание приватного бакета rustfs-init: image: amazon/aws-cli:latest depends_on: rustfs: condition: service_healthy environment: AWS_ACCESS_KEY_ID: rustfsadmin AWS_SECRET_ACCESS_KEY: rustfssecret entrypoint: > /bin/sh -c " aws --endpoint-url http://rustfs:9000 s3 mb s3://attachments || true; exit 0; " api: build: . environment: - DB_HOST=db - DB_USER=postgres - DB_PASSWORD=secret - DB_NAME=messenger - REDIS_HOST=redis - S3_ENDPOINT=http://rustfs:9000 - S3_ACCESS_KEY=rustfsadmin - S3_SECRET_KEY=rustfssecret - S3_BUCKET=attachments depends_on: db: condition: service_healthy redis: condition: service_started rustfs: condition: service_healthy deploy: resources: limits: cpus: '0.50' memory: 512M lb: image: nginx:1.25-alpine ports: - "8080:8080" volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro depends_on: - api volumes: pgdata: redisdata: rustfsdata: