From 5264bfd25835b6015ec736b8b169a44ecd24c116 Mon Sep 17 00:00:00 2001 From: kalicyh <34980061+kaliCYH@users.noreply.github.com> Date: Thu, 20 Feb 2025 10:56:51 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dockerfile移除网络下载 添加前端说明文档 修改静态文件调用 --- Dockerfile | 5 --- Dockerfile-pip | 8 +--- ZhiKongTaiWeb/README.md | 92 ++++++++++++++++++++++++++++++++++---- ZhiKongTaiWeb/package.json | 3 +- docker-compose.yml | 3 +- docs/Deployment.md | 9 ++++ manager/http_server.py | 2 +- 7 files changed, 98 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index bd19b514..9648b7b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,11 +37,6 @@ RUN poetry install --no-root # 从构建阶段复制虚拟环境和前端构建产物 COPY --from=frontend-builder /app/ZhiKongTaiWeb/dist /app/manager/static/webui -# 下载模型文件(断点续传 + 自动重试) -RUN mkdir -p /app/model/SenseVoiceSmall && \ - wget -O /app/model/SenseVoiceSmall/model.pt -c --tries=5 --waitretry=5 \ - https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt - # 设置虚拟环境路径 ENV PATH="/app/.venv/bin:$PATH" diff --git a/Dockerfile-pip b/Dockerfile-pip index 4eabb69f..00ad57f0 100755 --- a/Dockerfile-pip +++ b/Dockerfile-pip @@ -24,13 +24,7 @@ WORKDIR /app COPY requirements.txt . # 优化apt安装 -RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \ - echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \ - apt-get update && \ - apt-get install -y --no-install-recommends gcc libopus-dev ffmpeg && \ - rm -rf /var/lib/apt/lists/* && \ - # 直接使用系统Python - pip install --no-cache-dir -r requirements.txt \ +RUN pip install --no-cache-dir -r requirements.txt \ -i https://pypi.tuna.tsinghua.edu.cn/simple # 第三阶段:生产镜像 diff --git a/ZhiKongTaiWeb/README.md b/ZhiKongTaiWeb/README.md index e5b83116..4ddcc775 100644 --- a/ZhiKongTaiWeb/README.md +++ b/ZhiKongTaiWeb/README.md @@ -1,14 +1,88 @@ -# Vue 3 + Vite +# Vue 3 + Vite 项目配置文档 -项目使用Vue3 + Vite实现 +## 开发环境配置 -在当前目录执行以下命令进入开发模式 +### 使用 Poetry 配置开发环境 -``` -npm run dev +在项目根目录中执行以下命令安装 Python 依赖: + +```sh +poetry install ``` -执行以下命令打包 -``` -npm run build -``` \ No newline at end of file +--- + +## 安装项目依赖 + +你可以选择以下任意一个包管理工具(`npm`、`yarn` 或 `pnpm`)来管理项目依赖。 + +### 通用命令 + +- `install`:安装项目依赖 +- `dev`:同时启动前后端 +- `dev:ui`:启动前端 +- `dev:api`:启动后端 +- `dev:d`:在 Docker 环境下同时启动前后端 +- `build`:打包项目 + +--- + +### 使用 npm + +1. 安装依赖: + + ```sh + npm install + ``` + +2. 启动开发模式: + + ```sh + npm run dev + ``` + +3. 打包项目: + + ```sh + npm run build + ``` + +### 使用 yarn + +1. 安装依赖: + + ```sh + yarn install + ``` + +2. 启动开发模式: + + ```sh + yarn dev + ``` + +3. 打包项目: + + ```sh + yarn build + ``` + +### 使用 pnpm + +1. 安装依赖: + + ```sh + pnpm install + ``` + +2. 启动开发模式: + + ```sh + pnpm run dev + ``` + +3. 打包项目: + + ```sh + pnpm run build + ``` diff --git a/ZhiKongTaiWeb/package.json b/ZhiKongTaiWeb/package.json index bf87ab9a..7f488208 100644 --- a/ZhiKongTaiWeb/package.json +++ b/ZhiKongTaiWeb/package.json @@ -6,7 +6,8 @@ "scripts": { "dev": "concurrently -n 'Frontend,Backend' -c 'blue,green' 'yarn run dev:ui' 'npm run dev:api'", "dev:ui": "vite", - "dev:api": "cd .. && poetry run python manager/http_server.py", + "dev:api": "cd .. && poetry run python app.py", + "dev:d": "docker exec xiaozhi-env poetry run python app.py", "build": "vite build", "preview": "vite preview" }, diff --git a/docker-compose.yml b/docker-compose.yml index 26aa64e8..49e26d81 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,4 +9,5 @@ services: - "8000:8000" - "8002:8002" volumes: - - ./data:/app/data \ No newline at end of file + - ./data:/app/data + - ./models/SenseVoiceSmall/model.pt:/app/models/SenseVoiceSmall/model.pt \ No newline at end of file diff --git a/docs/Deployment.md b/docs/Deployment.md index a0f75e41..02c0ec41 100644 --- a/docs/Deployment.md +++ b/docs/Deployment.md @@ -112,6 +112,15 @@ LLM: - 线路二:百度网盘下载[SenseVoiceSmall](https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg&pwd=qvna) 提取码: `qvna` +huggingface地址: + +``` +https://huggingface.co/jinaai/jina-embeddings-v2-base-zh?clone=true +https://huggingface.co/FunAudioLLM/SenseVoiceSmall/tree/main?clone=true +``` + +镜像地址`https://hf-mirror.com/` + ## 运行状态确认 diff --git a/manager/http_server.py b/manager/http_server.py index 841ea876..565c1cf4 100644 --- a/manager/http_server.py +++ b/manager/http_server.py @@ -38,7 +38,7 @@ class WebUI: self.session_manager = SessionManager() # 添加静态文件路径 - self.static_path = os.path.join(root_dir, 'manager', 'static', 'webui') + self.static_path = os.path.join(root_dir, 'ZhiKongTaiWeb', 'dist') self.setup_routes() self.setup_cors()