services:
  halo:
    image: registry.fit2cloud.com/halo/halo:2
    restart: unless-stopped
    depends_on:
      halodb:
        condition: service_healthy
    networks:
      halo:
    volumes:
      - /opt/halo/halo2:/root/.halo2
    ports:
      - "1002:8090"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
      interval: 30s
      timeout: 5s
      retries: 5
      start_period: 30s
    environment:
      # JVM 参数，默认为 -Xmx256m -Xms256m，可以根据实际情况做调整，置空表示不添加 JVM 参数
      - JVM_OPTS=-Xms1G -Xmx1G
    command:
      - --spring.r2dbc.url=r2dbc:pool:mysql://halodb:3306/halo
      - --spring.r2dbc.username=root
      # MySQL 的密码，请保证与下方 MYSQL_ROOT_PASSWORD 的变量值一致。
      - --spring.r2dbc.password=password
      - --spring.sql.init.platform=mysql
      # 外部访问地址，请根据实际需要修改
      - --halo.external-url=https://blog.19950628.xyz 

  halodb:
    image: mysql:8.1.0
    restart: unless-stopped
    networks:
      halo:
    command: 
      - --default-authentication-plugin=caching_sha2_password
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_general_ci
      - --explicit_defaults_for_timestamp=true
    volumes:
      - /opt/halo/mysql/mysql:/var/lib/mysql
      - /opt/halo/mysql/mysqlBackup:/data/mysqlBackup 
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
      interval: 3s
      retries: 5
      start_period: 30s
    environment:
      # 请修改此密码，并对应修改上方 Halo 服务的 SPRING_R2DBC_PASSWORD 变量值
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=halo

networks:
  halo: