Browse Source

东莞POC验证OK

xuqh1 7 tháng trước cách đây
commit
da19aa4df7
10 tập tin đã thay đổi với 1925 bổ sung0 xóa
  1. 43 0
      .env
  2. 178 0
      README.md
  3. 189 0
      config/application.yaml
  4. 185 0
      docker-compose-base-gpu.yml
  5. 48 0
      docker-compose.yml
  6. 1180 0
      init.sql
  7. 2 0
      init_extra.sql
  8. 20 0
      install.sh
  9. 79 0
      install_docker.sh
  10. 1 0
      update_db.sh

+ 43 - 0
.env

@@ -0,0 +1,43 @@
+# Version of Elastic products
+STACK_VERSION=8.11.3
+
+# Port to expose Elasticsearch HTTP API to the host
+ES_PORT=9201
+
+# Set the Elasticsearch password
+ELASTIC_PASSWORD=8IpWQfcZXXmRsIkX7+yy
+
+
+# Increase or decrease based on the available host memory (in bytes)
+
+MEM_LIMIT=8073741824
+
+
+MYSQL_PASSWORD=llmllmllm
+MYSQL_PORT=3336
+
+# Port to expose minio to the host
+MINIO_CONSOLE_PORT=9001
+MINIO_PORT=9000
+
+MINIO_USER=root
+MINIO_PASSWORD=llmllmllm
+
+REDIS_PORT=6389
+REDIS_PASSWORD=llmllmllm
+
+SVR_HTTP_PORT=8080
+SVR_HTTP_HOST='llm-app'
+
+TIMEZONE='Asia/Shanghai'
+
+
+#HF_ENDPOINT=https://hf-mirror.com
+
+######## OS setup for ES ###########
+# sysctl vm.max_map_count
+# sudo sysctl -w vm.max_map_count=262144
+# However, this change is not persistent and will be reset after a system reboot.
+# To make the change permanent, you need to update the /etc/sysctl.conf file.
+# Add or update the following line in the file:
+# vm.max_map_count=262144

+ 178 - 0
README.md

@@ -0,0 +1,178 @@
+# POC部署说明
+## 文件目录说明
+```
+├── config
+│   └── application.yaml
+├── docker-compose-base-gpu.yml
+├── docker-compose.yml
+├── docker.tar.gz
+├── huggingface
+│   ├── hub
+│   └── modules
+├── images
+│   ├── elasticsearch-8.11.3.tgz
+│   ├── gotenberg-8.9.1.tgz
+│   ├── infinity-0.0.55.tgz
+│   ├── llm-app-55.tgz
+│   ├── llm-doc-parser.tgz
+│   ├── llm-rag-35.tgz
+│   ├── minio-RELEASE.2024-09-22T00-33-43Z.tgz
+│   ├── mysql-5.7.44.tgz
+│   ├── redis-7.2.4.tgz
+│   └── unstructured-api-0.0.80.tgz
+├── init_extra.sql
+├── init.sql
+├── install_docker.sh
+├── install.sh
+├── mysql.yaml
+├── README.md
+└── update_db.sh
+```
+## 部署架构图
+```mermaid
+flowchart TD
+    subgraph External
+        Client((Client))
+    end
+
+    subgraph Application["Application Layer"]
+        llm-app["llm-app
+        (RAG前后端应用层)"]
+    end
+
+    subgraph Storage["数据库中间件"]
+        MySQL[(MySQL)]
+        Redis[(Redis)]
+        MinIO[(MinIO)]
+        ES[(Elasticsearch)]
+    end
+
+    subgraph Services["Service Layer"]
+        gotenberg["Gotenberg
+        (PDF转换服务)"]
+        llm-rag["llm-rag
+        (RAG基础服务)"]
+        unstructured["Unstructured API
+        (Unstructured文档解析)"]
+        llm-infinity["LLM Infinity
+        (Embedding和Rerank
+        模型推理)"]
+        doc-parser["doc-parser
+        (文档解析聚合服务)"]
+    end
+
+    %% External connections
+    Client --> llm-app
+
+    %% Application layer connections
+    llm-app --> MySQL
+    llm-app --> Redis
+    llm-app --> MinIO
+    llm-app --> llm-rag
+    llm-app --> gotenberg
+
+    %% llm-rag connections
+    llm-rag --> ES
+    llm-rag --> unstructured
+    llm-rag --> llm-infinity
+    llm-rag --> doc-parser
+
+    %% Styling
+    classDef storage fill:#f9f,stroke:#333,stroke-width:2px
+    classDef service fill:#bbf,stroke:#333,stroke-width:2px
+    classDef application fill:#bfb,stroke:#333,stroke-width:2px
+    classDef client fill:#fff,stroke:#333,stroke-width:2px
+
+    class MySQL,Redis,MinIO,ES storage
+    class gotenberg,unstructured,llm-infinity,doc-parser service
+    class llm-app,llm-rag application
+    class Client client
+```
+## 服务配置
+
+### 后端服务配置
+[config/application.yaml](./config/application.yaml) 智能问答后端服务配置
+### Docker 环境变量
+查看 [.env](./.env)文件,内容如下
+```yaml
+# Version of Elastic products
+STACK_VERSION=8.11.3
+
+# Port to expose Elasticsearch HTTP API to the host
+ES_PORT=9201
+
+# Set the Elasticsearch password
+ELASTIC_PASSWORD=8IpWQfcZXXmRsIkX7+yy
+
+
+# Increase or decrease based on the available host memory (in bytes)
+
+MEM_LIMIT=8073741824
+
+
+MYSQL_PASSWORD=llmllmllm
+MYSQL_PORT=3336
+
+# Port to expose minio to the host
+MINIO_CONSOLE_PORT=9001
+MINIO_PORT=9000
+
+MINIO_USER=root
+MINIO_PASSWORD=llmllmllm
+
+REDIS_PORT=6389
+REDIS_PASSWORD=llmllmllm
+
+# 智能问答服务访问入口
+SVR_HTTP_PORT=8080
+SVR_HTTP_HOST='llm-app'
+
+TIMEZONE='Asia/Shanghai'
+```
+
+## 数据库脚本
+### 数据库初始化脚本
+[init.sql](init.sql),第一次启动MySQL时会自动执行,如果执行错误,需要手动再次执行
+
+### 额外的数据库初始化脚本
+由于MySQL安装初始化脚本有大小限制,目前是有个背景图片需要额外导入
+* 脚本 [init_extra.sql](init_extra.sql)
+* 在数据库完全启动之后手动通过脚本执行:
+  `bash update_db.sh`
+
+## 服务部署
+
+### 安装docker和docker compose
+1. 下载Docker二进制安装文件[docker.tar.gz](http://110.16.193.170:40002/share/UtURYif0)到当前目录
+2. 执行安装脚本 `./install_docker.sh`
+
+### docker-compose文件说明
+* docker-compose.yml            安装所有服务的入口,文件中定义app和rag服务,引用`docker-compose-base-gpu.yaml`
+    * llm-app 前后端服务
+    * llm-rag Python后端
+* docker-compose-base-gpu.yml   除了app和rag的所有服务的安装定义
+    * es: 向量数据库存储
+    * mysql:关系数据库
+    * redis:缓存数据库
+    * minio:对象存储
+    * gotenberg: 转pdf服务
+    * unstructured-api:  unstructured文档解析
+    * llm-infinity:embedding模型和rerank模型推理服务
+    * doc-parser 文件解析聚合服务,包括deepdoc和marker,并且依赖unstructured文档解析
+    * chat模型推理(待更新)
+        * vllm(优先)qwen2.5-72b + qwen2.5-7b + qwen2-vl-7b
+        * ollama 
+
+### 镜像文件
+下载镜像文件到[images](http://110.16.193.170:40002/share/eUvp3_tn)
+
+### 模型文件
+下载模型文件到[huggingface](http://110.16.193.170:40002/share/Nj4zYupf)
+> 注意:模型文件不包含chat模型,只有embedding、rerank和文档解析相关模型
+
+### 服务部署
+* 一键部署,前提是已经完成以上docker和dockercompose的安装
+```bash
+./install.sh
+```
+* 手动部署参考脚本`install.sh`

+ 189 - 0
config/application.yaml

@@ -0,0 +1,189 @@
+server:
+  port: 8000
+  compression:
+    enabled: true
+    mime-types: text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json
+
+spring:
+  application:
+    admin: 
+      enabled: true
+  freemarker:
+    check-template-location: false
+  profiles:
+    active: test
+  data:
+    redis:
+      repositories:
+        enabled: false
+  #  pid:
+  #    file: /自行指定位置/eladmin.pid
+
+  #配置 Jpa
+  jpa:
+    hibernate:
+      ddl-auto: none
+    open-in-view: true
+    properties:
+      hibernate:
+        dialect: org.hibernate.dialect.MySQL5InnoDBDialect
+        format_sql: true
+    showSql: false
+
+
+  redis:
+    #数据库索引
+    database: ${REDIS_DB:0}
+    host: ${REDIS_HOST:redis}
+    port: ${REDIS_PORT:6379}
+    password: ${REDIS_PWD:llmllmllm}
+    #连接超时时间
+    timeout: 5000
+
+  datasource:
+    druid:
+      db-type: com.alibaba.druid.pool.DruidDataSource
+      driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
+      url: jdbc:log4jdbc:mysql://${DB_HOST:mysql}:${DB_PORT:3306}/${DB_NAME:llm-app}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
+      username: ${DB_USER:root}
+      password: ${DB_PWD:llmllmllm}
+      # 初始连接数
+      initial-size: 5
+      # 最小连接数
+      min-idle: 15
+      # 最大连接数
+      max-active: 30
+      # 超时时间(以秒数为单位)
+      remove-abandoned-timeout: 180
+      # 获取连接超时时间
+      max-wait: 3000
+      # 连接有效性检测时间
+      time-between-eviction-runs-millis: 60000
+      # 连接在池中最小生存的时间
+      min-evictable-idle-time-millis: 300000
+      # 连接在池中最大生存的时间
+      max-evictable-idle-time-millis: 900000
+      # 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除
+      test-while-idle: true
+      # 指明是否在从池中取出连接前进行检验,如果检验失败, 则从池中去除连接并尝试取出另一个
+      test-on-borrow: true
+      # 是否在归还到池中前进行检验
+      test-on-return: false
+      # 检测连接是否有效
+      validation-query: select 1
+      # 配置监控统计
+      webStatFilter:
+        enabled: true
+      stat-view-servlet:
+        enabled: true
+        url-pattern: /druid/*
+        reset-enable: false
+      filter:
+        stat:
+          enabled: true
+          # 记录慢SQL
+          log-slow-sql: false
+          slow-sql-millis: 1000
+          merge-sql: true
+        wall:
+          config:
+            multi-statement-allow: true
+
+# 登录相关配置
+login:
+  #  是否限制单用户登录
+  single-login: false
+  # Redis用户登录缓存配置
+  user-cache:
+    # 存活时间/秒
+    idle-time: 21600
+  #  验证码
+  login-code:
+    #  验证码类型配置 查看 LoginProperties 类
+    code-type: arithmetic
+    #  登录图形验证码有效时间/分钟
+    expiration: 2
+    #  验证码高度
+    width: 111
+    #  验证码宽度
+    height: 36
+    # 内容长度
+    length: 2
+    # 字体名称,为空则使用默认字体
+    font-name:
+    # 字体大小
+    font-size: 25
+
+#jwt
+jwt:
+  header: Authorization
+  # 令牌前缀
+  token-start-with: Bearer
+  # 必须使用最少88位的Base64对该令牌进行编码
+  base64-secret: ZmQ0ZGI5NjQ0MDQwY2I4MjMxY2Y3ZmI3MjdhN2ZmMjNhODViOTg1ZGE0NTBjMGM4NDA5NzYxMjdjOWMwYWRmZTBlZjlhNGY3ZTg4Y2U3YTE1ODVkZDU5Y2Y3OGYwZWE1NzUzNWQ2YjFjZDc0NGMxZWU2MmQ3MjY1NzJmNTE0MzI=
+  # 令牌过期时间 此处单位/毫秒 ,默认4小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html
+  token-validity-in-seconds: 14400000
+  # 在线用户key
+  online-key: "online-token:"
+  # 验证码
+  code-key: "captcha-code:"
+  # token 续期检查时间范围(默认30分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期
+  detect: 1800000
+  # 续期时间范围,默认1小时,单位毫秒
+  renew: 3600000
+
+#是否允许生成代码,生产环境设置为false
+generator:
+  enabled: true
+
+#是否开启 swagger-ui
+swagger:
+  enabled: true
+
+# 文件存储路径
+file:
+  mac:
+    path: ~/file/
+    avatar: ~/avatar/
+  linux:
+    path: /home/eladmin/file/
+    avatar: /home/eladmin/avatar/
+  windows:
+    path: C:\eladmin\file\
+    avatar: C:\eladmin\avatar\
+  # 文件大小 /M
+  maxSize: 100
+  avatarMaxSize: 5
+
+task:
+  pool:
+    # 核心线程池大小
+    core-pool-size: 10
+    # 最大线程数
+    max-pool-size: 30
+    # 活跃时间
+    keep-alive-seconds: 60
+    # 队列容量
+    queue-capacity: 50
+
+#七牛云
+qiniu:
+  # 文件大小 /M
+  max-size: 15
+
+#邮箱验证码有效时间/秒
+code:
+  expiration: 300
+
+#密码加密传输,前端公钥加密,后端私钥解密
+rsa:
+  private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
+
+#MinIO配置
+minio:
+  #endpoint: http://152.136.191.250:2304
+  #accessKey: root
+  #secretKey: llmllmllm
+  bucketName: create-default
+  #ragUrl: http://rag.yangzhiqiang.tech/rag/index/{knowledegeId}/file/{fileId}?chunk_size={cs}&chunk_overlap={co}
+  #numHitUrl: http://rag.yangzhiqiang.tech/rag/retrieve/{knowledegeId}?query={q}&topk={t}

+ 185 - 0
docker-compose-base-gpu.yml

@@ -0,0 +1,185 @@
+services:
+  es01:
+    container_name: yusys-rag-es-01
+    image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
+    volumes:
+      - esdata01:/usr/share/elasticsearch/data
+    ports:
+      - ${ES_PORT}:9200
+    environment:
+      - node.name=es01
+      - ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
+      - bootstrap.memory_lock=false
+      - discovery.type=single-node
+      - xpack.security.enabled=true
+      - xpack.security.http.ssl.enabled=false
+      - xpack.security.transport.ssl.enabled=false
+      - TZ=${TIMEZONE}
+    mem_limit: ${MEM_LIMIT}
+    ulimits:
+      memlock:
+        soft: -1
+        hard: -1
+    healthcheck:
+      test: ["CMD-SHELL", "curl http://localhost:9200"]
+      interval: 10s
+      timeout: 10s
+      retries: 120
+    networks:
+      - yusys-rag
+    restart: always
+
+  mysql:
+    image: docker.byai.uk/library/mysql:5.7.44
+    container_name: yusys-rag-mysql
+    environment:
+      - MYSQL_ROOT_PASSWORD=${MYSQL_PASSWORD}
+      - TZ=${TIMEZONE}
+    command:
+      --max_connections=1000
+      --character-set-server=utf8mb4
+      --collation-server=utf8mb4_general_ci
+      --tls_version="TLSv1.2,TLSv1.3"
+      --init-file /data/application/init.sql
+    ports:
+      - ${MYSQL_PORT}:3306
+    volumes:
+      - mysql_data:/var/lib/mysql
+      - ./init.sql:/data/application/init.sql
+    networks:
+      - yusys-rag
+    healthcheck:
+      test: ["CMD", "mysqladmin" ,"ping", "-uroot", "-p${MYSQL_PASSWORD}"]
+      interval: 10s
+      timeout: 10s
+      retries: 3
+    restart: always
+
+  minio:
+    image: quay.io/minio/minio:RELEASE.2024-09-22T00-33-43Z
+    container_name: yusys-rag-minio
+    command: server --console-address ":9001" /data
+    ports:
+      - ${MINIO_PORT}:9000
+      - ${MINIO_CONSOLE_PORT}:9001
+    environment:
+      - MINIO_ROOT_USER=${MINIO_USER}
+      - MINIO_ROOT_PASSWORD=${MINIO_PASSWORD}
+      - TZ=${TIMEZONE}
+    volumes:
+      - minio_data:/data
+    networks:
+      - yusys-rag
+    restart: always
+
+  redis:
+    image: docker.byai.uk/library/redis:7.2.4
+    container_name: yusys-rag-redis
+    command: redis-server --requirepass ${REDIS_PASSWORD} --maxmemory 128mb --maxmemory-policy allkeys-lru
+    ports:
+      - ${REDIS_PORT}:6379
+    volumes:
+      - redis_data:/data
+    networks:
+      - yusys-rag
+    restart: always
+
+  gotenberg:
+    image: docker.byai.uk/gotenberg/gotenberg:8.9.1
+    command:
+      - gotenberg
+      - '--api-port=3000'
+      - '--api-timeout=60s'
+      - '--api-disable-health-check-logging'
+      - '--libreoffice-restart-after=10'
+      - '--libreoffice-auto-start'
+      - '--libreoffice-start-timeout=10s'
+      - '--libreoffice-max-queue-size=50'
+      - '--gotenberg-graceful-shutdown-duration=30s'
+    expose:
+      - "3000"
+    deploy:
+      replicas: 2
+      endpoint_mode: dnsrr
+    healthcheck:
+      test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
+      interval: 10s
+      timeout: 1s
+      retries: 3
+    user: "1001"
+    networks:
+      - yusys-rag
+    restart: always
+
+  unstructured-api:
+    image: downloads.unstructured.io/unstructured-io/unstructured-api:0.0.80
+    expose:
+      - "8000"
+    volumes:
+      - ./huggingface:/home/notebook-user/.cache/huggingface
+    deploy:
+      replicas: 4
+      endpoint_mode: dnsrr
+    networks:
+      - yusys-rag
+    restart: always
+
+  llm-infinity:
+    image: docker.byai.uk/michaelf34/infinity:0.0.55
+    container_name: yusys-rag-infinity
+    command: ["v2"]
+    environment:
+      - HF_ENDPOINT=https://hf-mirror.com
+      - INFINITY_PORT=8781
+      - INFINITY_MODEL_ID=BAAI/bge-reranker-v2-m3;BAAI/bge-large-zh;
+    ports:
+      - "8781:8781"
+    volumes:
+      - ./huggingface:/app/.cache/huggingface
+    deploy:
+      resources:
+        reservations:
+          devices:
+          - driver: nvidia
+            device_ids: ['4']
+            # count: all
+            capabilities: [gpu]
+    networks:
+      - yusys-rag
+    restart: always
+
+  doc-parser:
+    image: 192.168.107.2:5000/yusyscloud/llm-doc-parser:dev-32
+    container_name: yusys-rag-doc
+    environment:
+      - UNSTRUCTURED_API_URL=http://unstructured-api:8000/general/v0/general
+      - SPLIT_PDF_CONCURRENCY_LEVEL=15
+    ports:
+      - "8023:8023"
+    volumes:
+      - ./huggingface:/root/.cache/huggingface
+    deploy:
+      resources:
+        reservations:
+          devices:
+          - driver: nvidia
+            device_ids: ['4']
+            #count: all
+            capabilities: [gpu]
+    networks:
+      - yusys-rag
+    restart: always
+
+volumes:
+  esdata01:
+    driver: local
+  mysql_data:
+    driver: local
+  minio_data:
+    driver: local
+  redis_data:
+    driver: local
+
+networks:
+  yusys-rag:
+    driver: bridge

+ 48 - 0
docker-compose.yml

@@ -0,0 +1,48 @@
+include:
+  - path: ./docker-compose-base-gpu.yml
+    env_file: ./.env
+
+services:
+  llm-app:
+    depends_on:
+      mysql:
+        condition: service_healthy
+      es01:
+        condition: service_healthy
+    image: 192.168.107.2:5000/yusyscloud/llm-app:0826-0830-55
+    container_name: llm-app
+    ports:
+      - ${SVR_HTTP_PORT}:80
+    volumes:
+      - ./config/application.yaml:/application.yml
+    healthcheck:
+      test: ["CMD", "curl", "-f", "http://localhost:80"]
+      interval: 30s
+      timeout: 10s
+      retries: 3
+      start_period: 30s
+    environment:
+      - TZ=${TIMEZONE}
+    networks:
+      - yusys-rag
+    restart: always
+
+  llm-rag:
+    depends_on:
+      llm-app:
+        condition: service_healthy
+    container_name: yusys-rag-base
+    image: 192.168.107.2:5000/yusyscloud/llm-rag:splitload-keyword-retrieve-35
+    ports:
+      - 8001:8001
+    environment:
+      - llm_app_url=http://llm-app:80
+      - TZ=${TIMEZONE}
+    healthcheck:
+      test: ["CMD-SHELL", "curl http://localhost:8001/health"]
+      interval: 10s
+      timeout: 10s
+      retries: 120
+    networks:
+      - yusys-rag
+    restart: always

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1180 - 0
init.sql


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 2 - 0
init_extra.sql


+ 20 - 0
install.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# get current directory
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+# load images
+cd images
+for file in *.tgz; do docker load < "$file"; done
+
+cd $DIR
+
+# docker compose
+docker compose up -d 
+
+# Add extra db data
+docker exec -i yusys-rag-mysql mysql -uroot -pllmllmllm < init.sql
+
+# docker compose logs
+docker compose logs -f
+

+ 79 - 0
install_docker.sh

@@ -0,0 +1,79 @@
+#!/bin/bash
+
+docker_file_dir="$(pwd)/docker"
+
+function get_docker_install() {
+  (cd "${docker_file_dir}" && chmod +x docker_off-line_install.sh && ./docker_off-line_install.sh -f docker-26.1.0.tgz >/dev/null 2>&1 && systemctl start docker >/dev/null 2>&1 && systemctl enable docker >/dev/null 2>&1)
+}
+
+function check_docker_status() {
+  [ ! -z "$(docker ps 2>/dev/null)" ]
+}
+
+function check_compose_status() {
+  [ ! -z "$(docker compose 2>/dev/null)" ]
+}
+
+function check_docker_compose_status() {
+  [ ! -z "$(docker-compose 2>/dev/null)" ]
+}
+
+function get_compose_install() {
+  echo "try to install docker compose service"
+  (DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} && mkdir -p $DOCKER_CONFIG/cli-plugins && cp "${docker_file_dir}/docker-compose" $DOCKER_CONFIG/cli-plugins/docker-compose && chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose)
+
+  (check_compose_status || get_docker_compose_install)
+
+}
+
+function get_docker_compose_install() {
+  (cp "${docker_file_dir}/docker-compose" /usr/local/bin/ && chmod +x /usr/local/bin/docker-compose && ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose)
+  (check_docker_compose_status || echo "Please install docker compose yourself")
+}
+
+function check_docker_compose_install() {
+
+  check_compose_status || (check_docker_compose_status || get_compose_install)
+  echo "The docker compose service is running normally"
+}
+
+function check_docker_install() {
+  # check if "docker.tar.gz" exists, if not, echo an error message
+  [ ! -f "${docker_file_dir}/docker.tar.gz" ] && echo "Error: ${docker_file_dir}/docker.tar.gz does not exist" && exit 1
+
+  # decompress "docker.tar.gz"  into the current directory
+  tar -zxf "docker.tar.gz" --directory "$(pwd)"
+
+  if [ -x "$(command -v 'docker')" ]; then
+
+  check_docker_status || (systemctl start docker 2>/dev/null || service docker start 2>/dev/null)
+
+  check_docker_status || (get_docker_install )
+
+  check_docker_status && echo "The docker service is running normally" || echo "Please install docker yourself"
+
+  else
+
+  echo "It is detected that the system does not have docker service installed, try to install docker service"
+
+  get_docker_install
+
+  check_docker_status && echo "The docker service is running normally" || echo "Please install docker yourself"
+  fi
+}
+
+# check if the script is run as root
+if [ "$(id -u)" != "0" ]; then
+  echo "Error: This script must be run as root" 1>&2
+  exit 1
+fi
+
+# check if the script is run in the current directory
+if [ "$(pwd)" != "$(dirname "$0")" ]; then
+  echo "Error: This script must be run in the current directory" 1>&2
+  exit 1
+fi
+
+# run the script
+check_docker_install
+check_docker_compose_install

+ 1 - 0
update_db.sh

@@ -0,0 +1 @@
+docker exec -i yusys-rag-mysql mysql -uroot -pllmllmllm < init_extra.sql

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác