version: '3'
services:
  simsdb:
    image: registry.cn-guangzhou.aliyuncs.com/hzbb/mysql:5.7.44
    restart: always
    container_name: simsdb
    environment:
      TZ: Asia/Shanghai
      MYSQL_DATABASE: sims
      MYSQL_USER: test
      MYSQL_PASSWORD: admin@123456
      MYSQL_ROOT_PASSWORD: admin@123456
    ports:
      - 3306:3306
    volumes:
      - ./MySQL/data:/var/lib/mysql
      - ./MySQL/config/my.cnf:/etc/mysql/my.cnf
      - ./MySQL/mysql-files:/var/lib/mysql-files
      - ./MySQL/docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d/
    command:
      --max_connections=1000
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --default-authentication-plugin=mysql_native_password

  simsbe:  
    image: registry.cn-guangzhou.aliyuncs.com/hzbb/python:3.7.0
    restart: always
    hostname: simsbe
    container_name: simsbe
    volumes:
      - ./:/simsBE
      - ./module:/module
    depends_on:
      - simsdb
    environment:
      - TZ=Asia/Shanghai
    command: bash /module/run.sh
    healthcheck:
      test: ["CMD", "curl", "-f", "http://127.0.0.1:8000/students/"]
      interval: 20s
      timeout: 5s
      retries: 3
      start_period: 10s

  simsfe:
    image: registry.cn-guangzhou.aliyuncs.com/hzbb/nginx:1.26.0
    restart: always
    container_name: simsfe
    environment:
      TZ: Asia/Shanghai
    ports:
      - 80:80
      - 443:443
    depends_on:
      - simsbe
      - simsdb
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/cert:/etc/nginx/cert
      - ./front:/simsFE

  autoheal:
    image: registry.cn-guangzhou.aliyuncs.com/hzbb/autoheal:1.2.0
    restart: always
    container_name: sims-autoheal
    environment:
      - AUTOHEAL_CONTAINER_LABEL=all
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
