healthcheck

service_healthy

  mysql:
    image: mysql:8.4
    container_name: mysql
    ports:
      - 3306:3306
    restart: unless-stopped
    privileged: true
    command: mysqld --local_infile=ON
    environment:
      MYSQL_ROOT_HOST: "%"
      MYSQL_DATABASE: lottery
      MYSQL_ROOT_PASSWORD: 数据库密码
      TZ: Asia/Shanghai
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 5s
      timeout: 3s
      retries: 10
      start_period: 30s
    volumes:
      - ./mysql/mysql:/var/lib/mysql
bigdata_api:
  image: reg.wuxiaoyang.top/lcedu/bigdata_api:1.0.0
  container_name: bigdata_api
  restart: always
  privileged: true
  ports:
    - 5005:5005
  environment:
    - TZ=Asia/Shanghai
    - VIRTUAL_HOST=api.osharp.top
    - VIRTUAL_PORT=5005
    - LETSENCRYPT_HOST=api.osharp.top
    - LETSENCRYPT_EMAIL=shiningrise@qq.com
  volumes:
    - "/data/bigdata/Database.json:/app/Configuration/Database.json"
    - "/data/bigdata/upload:/app/wwwroot/upload"
  command: ["/app/wait-for-it.sh", "mysql:3306", "-t", "120", "--", "dotnet", "Admin.NET.Web.Entry.dll"]
  healthcheck:  # ← 新增健康检查
    test: ["CMD", "curl", "-f", "http://localhost:5005/health"]  # 请根据实际健康检查端点调整
    interval: 10s
    timeout: 5s
    retries: 5
    start_period: 40s
  depends_on:
    mysql:
      condition: service_healthy
  networks:
    - default

bigdata_web:
  image: reg.wuxiaoyang.top/lcedu/bigdata_web:1.0.0
  container_name: bigdata_web
  restart: always
  ports:
    - 8080:80
  privileged: true
  environment:
    - TZ=Asia/Shanghai
    - VIRTUAL_HOST=bigdata.swl.ink
    - VIRTUAL_PORT=80
    - LETSENCRYPT_HOST=bigdata.swl.ink
    - LETSENCRYPT_EMAIL=shiningrise@qq.com
  volumes:
    - "/data/bigdata/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro"
  networks:
    - default
  depends_on:
    bigdata_api:
      condition: service_healthy  # ← 等待 API 健康后再启动

发表评论