version: '3.9'
services:
  mysql:
    image: mysql:8.0.26
    container_name: mysql
    command:
    # MySQL8的密码验证方式默认是 caching_sha2_password，但是很多的连接工具还不支持该方式
    # 就需要手动设置下mysql的密码认证方式为以前的 mysql_native_password 方式
      --default-authentication-plugin=mysql_native_password
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --lower-case-table-names=1 # 设置表名大小写不敏感
    # docker的重启策略：在容器退出时总是重启容器，但是不考虑在Docker守护进程启动时就已经停止了的容器
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: huansi@V3 # root用户的密码
      MYSQL_USER: huansi # 创建新用户
      MYSQL_PASSWORD: huansi.net # 新用户的密码
      TZ: Asia/Shanghai
    ports:
      - 3306:3306
    volumes:
      - ./mysql/data:/var/lib/mysql
      - ./mysql/conf:/etc/mysql/conf.d
      - ./mysql/logs:/logs 
  
  iot-job: 
    image: registry.cn-hangzhou.aliyuncs.com/hsyl_iot/xxl-job:v3
    restart: always
    ports:
      - "8099:8080"
    environment:
      PARAMS: "--spring.datasource.url=jdbc:mysql://mysql:3306/iot_job?Unicode=true&characterEncoding=UTF-8&useSSL=false --spring.datasource.username=root --spring.datasource.password=huansi@V3"    
    depends_on:
      - mysql

  iot-dbapi:
    image: registry.cn-hangzhou.aliyuncs.com/hsyl_iot/db-api:v3
    ports:
      - "8520:8520"
      - "8523:8523"
      - "8525:8525"
    environment:
      - DB_URL=jdbc:mysql://mysql:3306/iot_dbapi?useSSL=false&characterEncoding=UTF-8&serverTimezone=GMT%2B8
      - DB_USERNAME=root
      - DB_PASSWORD=huansi@V3
      - DB_DRIVER=com.mysql.cj.jdbc.Driver
      - API_CONTEXT=api
    restart: always
    depends_on:
      - mysql
  
  iot-interface:
    image: registry.cn-hangzhou.aliyuncs.com/hsyl_iot/interface-service:v3
    restart: always
    ports:
      - "8488:8080"
    env_file:
      - tb-node.hybrid.env
    environment:
      - HTTP_BIND_PORT=8080
      - KAFKA_K2_ENABLED=true
      - KAFKA_K2_TOPIC_PRE=iot-v3
      - KAFKA_K2_BOOTSTRAP_SERVERS=kafka-sync:9092
      - HS_TIME_TASK_LOCAL=true
      - SERVER_JWT_LOGIN_URL=http://tb-core1:8080
      - IOT_DBAPI_URL=http://192.168.4.18:8520
      - CACHE_TYPE=redis
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - HS_GAODE_KEY=2505c76db7cb1455c89b7233f65638ba