services:
  api:
    build:
      context: .
      dockerfile: apps/api/Dockerfile
    container_name: mana-media-api
    restart: unless-stopped
    ports:
      - "3050:3050"
    environment:
      - NODE_ENV=production
      - PORT=3050
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - S3_ENDPOINT=minio
      - S3_PORT=9000
      - S3_USE_SSL=false
      - S3_ACCESS_KEY=${S3_ACCESS_KEY:-minioadmin}
      - S3_SECRET_KEY=${S3_SECRET_KEY:-minioadmin}
      - S3_BUCKET=mana-media
    depends_on:
      - redis
      - minio
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3050/api/v1/health"]
      interval: 30s
      timeout: 10s
      retries: 3

  redis:
    image: redis:7-alpine
    container_name: mana-media-redis
    restart: unless-stopped
    volumes:
      - redis_data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

  minio:
    image: minio/minio:latest
    container_name: mana-media-minio
    restart: unless-stopped
    command: server /data --console-address ":9001"
    environment:
      - MINIO_ROOT_USER=${S3_ACCESS_KEY:-minioadmin}
      - MINIO_ROOT_PASSWORD=${S3_SECRET_KEY:-minioadmin}
    volumes:
      - minio_data:/data
    ports:
      - "9010:9000"
      - "9011:9001"
    healthcheck:
      test: ["CMD", "mc", "ready", "local"]
      interval: 30s
      timeout: 20s
      retries: 3

volumes:
  redis_data:
  minio_data:
