services:
  mysql:
    image: registry.cn-hangzhou.aliyuncs.com/pull-image/mysql:8.0
    container_name: zzyl-mysql
    restart: unless-stopped
    environment:
      TZ: ${TZ}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_USER: ${MYSQL_APP_USER}
      MYSQL_PASSWORD: ${MYSQL_APP_PASSWORD}
    ports:
      - "${MYSQL_PORT}:3306"
    command:
      - --default-authentication-plugin=mysql_native_password
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_general_ci
    volumes:
      - mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD-SHELL", "mysqladmin ping -uroot -p${MYSQL_ROOT_PASSWORD}"]
      interval: 10s
      timeout: 5s
      retries: 10

  redis:
    image: registry.cn-hangzhou.aliyuncs.com/pull-image/redis:7-alpine
    container_name: zzyl-redis
    restart: unless-stopped
    environment:
      TZ: ${TZ}
    ports:
      - "${REDIS_PORT}:6379"
    command: >
      sh -c "redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}"
    volumes:
      - redis_data:/data
    healthcheck:
      test: ["CMD-SHELL", "redis-cli -a ${REDIS_PASSWORD} ping"]
      interval: 10s
      timeout: 5s
      retries: 10

volumes:
  mysql_data:
  redis_data:
