services:
  one-hub:
    image: martialbe/one-api:v0.14.23
    container_name: ${CONTAINER_NAME}
    restart: always
    ports:
      - ${PANEL_APP_PORT_HTTP}:3000
    networks:
      - 1panel-network
    command: --log-dir /app/logs
    volumes:
      - ./data:/data
      - ./logs:/app/logs
    environment:
      - SQL_DSN=root:${PANEL_DB_ROOT_PASSWORD}@tcp(${CONTAINER_NAME}-mysql:3306)/${PANEL_DB_NAME}
      - TZ=Asia/Shanghai
      - REDIS_CONN_STRING=redis://${CONTAINER_NAME}-redis
      - USER_TOKEN_SECRET=${USER_TOKEN_SECRET}
      - ERROR_LOG_ENABLED=true
    depends_on:
      - redis
      - mysql
    healthcheck:
      test:
        - CMD-SHELL
        - 'wget -q -O - http://localhost:3000/api/status | grep -o ''"success":\s*true''
          | awk -F: ''{print $$2}'''
      interval: 30s
      timeout: 10s
      retries: 3
    labels:
      createdBy: Apps
  mysql:
    image: mysql:8.2
    container_name: ${CONTAINER_NAME}-mysql
    restart: always
    volumes:
      - onehub-mysql_data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${PANEL_DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=${PANEL_DB_NAME}
    networks:
      - 1panel-network
  redis:
    image: redis:latest
    container_name: ${CONTAINER_NAME}-redis
    restart: always
    networks:
      - 1panel-network
volumes:
  onehub-mysql_data: null
networks:
  1panel-network:
    external: true
