services:
  mysql:
    image: mysql:8.4
    restart: unless-stopped
    env_file:
      - ../backend/.env
    environment:
      TZ: Asia/Shanghai
    volumes:
      - mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -uroot -p\"$${MYSQL_ROOT_PASSWORD}\""]
      interval: 10s
      timeout: 5s
      retries: 10

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

  minio:
    image: minio/minio:RELEASE.2025-09-07T16-13-09Z
    restart: unless-stopped
    command: server /data --console-address ":9001"
    env_file:
      - ../backend/.env
    environment:
      TZ: Asia/Shanghai
    volumes:
      - minio_data:/data
    healthcheck:
      test: ["CMD", "mc", "ready", "local"]
      interval: 10s
      timeout: 5s
      retries: 10

  backend:
    build:
      context: ../backend
    restart: unless-stopped
    env_file:
      - ../backend/.env
    volumes:
      - ../backend/logs:/app/logs
    depends_on:
      mysql:
        condition: service_healthy
      redis:
        condition: service_healthy
      minio:
        condition: service_healthy
    expose:
      - "8080"

  frontend:
    build:
      context: ..
      dockerfile: frontend/Dockerfile
    restart: unless-stopped
    depends_on:
      - backend
    ports:
      - "7890:80"

volumes:
  mysql_data:
  redis_data:
  minio_data:
