services:
  # MySQL 数据库服务
  mysql:
    image: mysql:8.0
    container_name: SmartFlow-mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root_password_123  # Root 用户密码
      MYSQL_DATABASE: smartflow                 # 初始创建的数据库名
      MYSQL_USER: smartflow_user                # 业务用户
      MYSQL_PASSWORD: smartflow_password_456    # 业务用户密码
    ports:
      - "3306:3306"
    volumes:
      - ./docker/mysql/data:/var/lib/mysql    # 数据持久化，防止容器删了数据丢失
    command: --default-authentication-plugin=mysql_native_password # 确保 GORM 连接兼容性

  # Redis 缓存服务
  redis:
    image: redis:latest
    container_name: redflow-redis
    restart: always
    command: redis-server --requirepass redis_password_789 # 设置 Redis 访问密码
    ports:
      - "6379:6379"
    volumes:
      - ./docker/redis/data:/data

# 定义持久化卷的本地路径
volumes:
  mysql_data:
  redis_data: