mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-28 10:03:54 +08:00
update:优化docker编译
This commit is contained in:
+37
-11
@@ -1,18 +1,44 @@
|
|||||||
|
# 第一阶段:构建依赖
|
||||||
|
FROM python:3.10-slim as builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
|
||||||
|
# 安装构建依赖
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
gcc \
|
||||||
|
libopus-dev \
|
||||||
|
ffmpeg && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# 安装Python依赖到虚拟环境
|
||||||
|
RUN python -m venv /opt/venv
|
||||||
|
ENV PATH="/opt/venv/bin:$PATH"
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
||||||
|
|
||||||
|
# 第二阶段:生产镜像
|
||||||
FROM python:3.10-slim
|
FROM python:3.10-slim
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get upgrade -y \
|
|
||||||
&& apt-get install -y libopus-dev ffmpeg \
|
|
||||||
&& apt-get clean \
|
|
||||||
&& apt-get autoremove -y
|
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR /opt/xiaozhi-es32-server
|
WORKDIR /opt/xiaozhi-es32-server
|
||||||
|
|
||||||
COPY . /opt/xiaozhi-es32-server
|
# 从构建阶段复制虚拟环境
|
||||||
|
COPY --from=builder /opt/venv /opt/venv
|
||||||
|
|
||||||
# Clean unnecessary files to reduce image size
|
# 安装运行时依赖
|
||||||
RUN pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
libopus0 \
|
||||||
|
ffmpeg && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
## Start the application
|
# 设置虚拟环境路径
|
||||||
|
ENV PATH="/opt/venv/bin:$PATH"
|
||||||
|
|
||||||
|
# 复制应用代码
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# 启动应用
|
||||||
CMD ["python", "app.py"]
|
CMD ["python", "app.py"]
|
||||||
@@ -58,21 +58,21 @@
|
|||||||
|
|
||||||
如果你的电脑是`arm`架构的电脑,请暂时使用`方式二:本地源码运行`。`arm`架构需要再等几天,因为目前还没有适配arm架构的镜像。
|
如果你的电脑是`arm`架构的电脑,请暂时使用`方式二:本地源码运行`。`arm`架构需要再等几天,因为目前还没有适配arm架构的镜像。
|
||||||
|
|
||||||
1. 安装docker
|
### 1. 安装docker
|
||||||
|
|
||||||
如果您的电脑还没安装docker,可以按照这里的教程安装:[docker安装](https://www.runoob.com/docker/ubuntu-docker-install.html)
|
如果您的电脑还没安装docker,可以按照这里的教程安装:[docker安装](https://www.runoob.com/docker/ubuntu-docker-install.html)
|
||||||
|
|
||||||
2. 创建目录
|
### 2. 创建目录
|
||||||
|
|
||||||
安装完后,你需要为这个项目找一个安放配置文件的目录,我们暂且称它为`项目目录`,这个目录最好是一个新建的空的目录。
|
安装完后,你需要为这个项目找一个安放配置文件的目录,我们暂且称它为`项目目录`,这个目录最好是一个新建的空的目录。
|
||||||
|
|
||||||
3. 下载配置文件
|
### 3. 下载配置文件
|
||||||
|
|
||||||
用浏览器打开[这个链接](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/config.yaml)。
|
用浏览器打开[这个链接](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/config.yaml)。
|
||||||
|
|
||||||
在页面的右侧找到名称为`RAW`按钮,在`RAW`按钮的旁边,找到下载的图标,点击下载按钮,下载`config.yaml`文件。 把文件下载到你的`项目目录`。
|
在页面的右侧找到名称为`RAW`按钮,在`RAW`按钮的旁边,找到下载的图标,点击下载按钮,下载`config.yaml`文件。 把文件下载到你的`项目目录`。
|
||||||
|
|
||||||
4. 修改配置文件
|
### 4. 修改配置文件
|
||||||
|
|
||||||
修改刚才你下载的`config.yaml`文件,配置本项目所需的各种参数。默认的LLM使用的是`ChatGLMLLM`,你需要配置密钥,才能启动。
|
修改刚才你下载的`config.yaml`文件,配置本项目所需的各种参数。默认的LLM使用的是`ChatGLMLLM`,你需要配置密钥,才能启动。
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ LLM:
|
|||||||
|
|
||||||
有些服务,比如如果你使用`Dify`、`豆包的TTS`,是需要密钥的,记得在配置文件加上哦!
|
有些服务,比如如果你使用`Dify`、`豆包的TTS`,是需要密钥的,记得在配置文件加上哦!
|
||||||
|
|
||||||
5. 执行docker命令
|
### 5. 执行docker命令
|
||||||
|
|
||||||
打开命令行工具,`cd` 进入到你的`项目目录`,执行以下命令
|
打开命令行工具,`cd` 进入到你的`项目目录`,执行以下命令
|
||||||
|
|
||||||
@@ -144,13 +144,17 @@ docker logs -f xiaozhi-esp32-server
|
|||||||
正常来说,假设你的ip是`192.168.1.25`,那么你的接口地址就是:`ws://192.168.1.25:8000`。这个信息很有用的,后面`编译esp32固件`需要用到。
|
正常来说,假设你的ip是`192.168.1.25`,那么你的接口地址就是:`ws://192.168.1.25:8000`。这个信息很有用的,后面`编译esp32固件`需要用到。
|
||||||
|
|
||||||
后期如果想升级版本,可以这么操作
|
后期如果想升级版本,可以这么操作
|
||||||
|
|
||||||
1、备份好`config.yaml`文件,一些关键的配置到时复制到新的`config.yaml`文件里。
|
1、备份好`config.yaml`文件,一些关键的配置到时复制到新的`config.yaml`文件里。
|
||||||
|
|
||||||
2、执行以下命令
|
2、执行以下命令
|
||||||
|
|
||||||
```
|
```
|
||||||
docker stop xiaozhi-esp32-server
|
docker stop xiaozhi-esp32-server
|
||||||
docker rm xiaozhi-esp32-server
|
docker rm xiaozhi-esp32-server
|
||||||
docker rmi ccr.ccs.tencentyun.com/xinnan/xiaozhi-esp32-server:latest
|
docker rmi ccr.ccs.tencentyun.com/xinnan/xiaozhi-esp32-server:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
3.按本教程重新来一遍
|
3.按本教程重新来一遍
|
||||||
|
|
||||||
|
|
||||||
@@ -343,4 +347,6 @@ VAD:
|
|||||||
|
|
||||||
# 鸣谢
|
# 鸣谢
|
||||||
|
|
||||||
- 本项目受[百聆语音对话机器人](https://github.com/wwbin2017/bailing)项目启发,基于该项目的基础思路完成实现。
|
- 本项目受[百聆语音对话机器人](https://github.com/wwbin2017/bailing)项目启发,基于该项目的基础思路完成实现。
|
||||||
|
- 感谢[腾讯云](https://cloud.tencent.com/)为本次项目提供免费docker镜像空间。
|
||||||
|
- 感谢[十方融海](https://www.tenclass.com/)在小智通讯协议上提供充分的文档支持。
|
||||||
+3
-1
@@ -371,4 +371,6 @@ VAD:
|
|||||||
# Acknowledgments
|
# Acknowledgments
|
||||||
|
|
||||||
- This project is inspired by the [Bailin Voice Dialogue Robot](https://github.com/wwbin2017/bailing) project, and the
|
- This project is inspired by the [Bailin Voice Dialogue Robot](https://github.com/wwbin2017/bailing) project, and the
|
||||||
basic idea of the project is completed.
|
basic idea of the project is completed。
|
||||||
|
- Thanks to [Tencent Cloud] (https://cloud.tencent.com/) for providing free docker space for this project。
|
||||||
|
- Thanks to [tenclass](https://www.tenclass.com/)Provide adequate documentation support on Xiaozhi Communication Protocol。
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ docker build -t xiaozhi-esp32-server:local -f ./Dockerfile .
|
|||||||
docker stop xiaozhi-esp32-server
|
docker stop xiaozhi-esp32-server
|
||||||
docker rm xiaozhi-esp32-server
|
docker rm xiaozhi-esp32-server
|
||||||
|
|
||||||
|
cd /Users/hrz/myworkspace/docker-java-env/thirddata/
|
||||||
cp /Users/hrz/myworkspace/esp32/xiaozhi-esp32-server/config.yaml ./
|
cp /Users/hrz/myworkspace/esp32/xiaozhi-esp32-server/config.yaml ./
|
||||||
docker run -d --name xiaozhi-esp32-server --restart always -p 8000:8000 -v $(pwd)/config.yaml:/opt/xiaozhi-es32-server/config.yaml xiaozhi-esp32-server:local
|
docker run -d --name xiaozhi-esp32-server --restart always -p 8000:8000 -v $(pwd)/config.yaml:/opt/xiaozhi-es32-server/config.yaml xiaozhi-esp32-server:local
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user