mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
🎈 perf: 修改uv相关
This commit is contained in:
parent
b5e7170d10
commit
1f6897942b
5 changed files with 24 additions and 56 deletions
7
.dockerignore
Normal file
7
.dockerignore
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
.git
|
||||
__pycache__
|
||||
*.pyc
|
||||
.env
|
||||
Dockerfile
|
||||
LICENSE
|
||||
*.md
|
||||
28
Dockerfile
28
Dockerfile
|
|
@ -1,29 +1,9 @@
|
|||
# 第一阶段:构建Python依赖
|
||||
FROM python:3.10-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY main/xiaozhi-server/requirements.txt .
|
||||
|
||||
# 优化apt安装
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# 第三阶段:生产镜像
|
||||
FROM python:3.10-slim
|
||||
FROM kalicyh/uv:v3.10_xiaozhi
|
||||
|
||||
WORKDIR /opt/xiaozhi-esp32-server
|
||||
|
||||
# 优化apt安装
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends libopus0 ffmpeg && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 从构建阶段复制Python包和前端构建产物
|
||||
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
||||
|
||||
# 复制应用代码
|
||||
COPY main/xiaozhi-server/ .
|
||||
|
||||
# 启动应用
|
||||
CMD ["python", "app.py"]
|
||||
RUN uv sync
|
||||
|
||||
CMD ["uv", "run", "app.py"]
|
||||
|
|
@ -117,39 +117,28 @@ docker run -it --name xiaozhi-env --restart always --security-opt seccomp:unconf
|
|||
-p 8000:8000 \
|
||||
-p 8002:8002 \
|
||||
-v ./:/app \
|
||||
kalicyh/poetry:v3.10_xiaozhi
|
||||
kalicyh/uv:v3.10_xiaozhi
|
||||
```
|
||||
|
||||
然后就和正常开发一样了
|
||||
|
||||
再次进入
|
||||
```sh
|
||||
docker exec -it xiaozhi-env /bin/bash
|
||||
```
|
||||
|
||||
## 5.安装依赖
|
||||
|
||||
在刚刚的打开的终端运行
|
||||
|
||||
```sh
|
||||
poetry install --no-root
|
||||
```
|
||||
|
||||
```sh
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends libopus0 ffmpeg
|
||||
```
|
||||
|
||||
速度慢可以尝试使用清华镜像
|
||||
|
||||
```sh
|
||||
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
|
||||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list
|
||||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends libopus0 ffmpeg
|
||||
uv sync
|
||||
```
|
||||
|
||||
## 6.运行项目
|
||||
|
||||
```sh
|
||||
poetry run python app.py
|
||||
uv run app.py
|
||||
```
|
||||
|
||||
# 方式三:本地源码运行
|
||||
|
|
@ -200,8 +189,7 @@ conda install ffmpeg -y
|
|||
conda activate xiaozhi-esp32-server
|
||||
# 进入到你的项目根目录,再进入main/xiaozhi-server
|
||||
cd main/xiaozhi-server
|
||||
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
|
||||
pip install -r requirements.txt
|
||||
uv sync
|
||||
```
|
||||
|
||||
## 3.下载语音识别模型文件
|
||||
|
|
|
|||
15
main/xiaozhi-server/Dockerfile
Normal file → Executable file
15
main/xiaozhi-server/Dockerfile
Normal file → Executable file
|
|
@ -1,16 +1,9 @@
|
|||
# 第一阶段:构建 Python 依赖
|
||||
FROM kalicyh/poetry:v3.10_xiaozhi AS builder
|
||||
FROM kalicyh/uv:v3.10_xiaozhi
|
||||
|
||||
WORKDIR /opt/xiaozhi-esp32-server
|
||||
|
||||
# 同时拷贝本地环境.venv
|
||||
COPY . .
|
||||
# 检查是否有缺失
|
||||
RUN poetry install --no-root
|
||||
COPY main/xiaozhi-server/ .
|
||||
|
||||
# 设置虚拟环境路径
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
RUN uv sync
|
||||
|
||||
# 启动应用
|
||||
ENTRYPOINT ["poetry", "run", "python"]
|
||||
CMD ["app.py"]
|
||||
CMD ["uv", "run", "app.py"]
|
||||
Loading…
Reference in a new issue