diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..3c31ecd08 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git +__pycache__ +*.pyc +.env +Dockerfile +LICENSE +*.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index aaa431037..4d0d90e1b 100755 --- a/Dockerfile +++ b/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"] \ No newline at end of file +RUN uv sync + +CMD ["uv", "run", "app.py"] \ No newline at end of file diff --git a/docs/Deployment.md b/docs/Deployment.md index 84b962ed2..a03eb322f 100644 --- a/docs/Deployment.md +++ b/docs/Deployment.md @@ -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.下载语音识别模型文件 diff --git a/docs/images/__init__.py b/docs/images/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/main/xiaozhi-server/Dockerfile b/main/xiaozhi-server/Dockerfile old mode 100644 new mode 100755 index 3ca8ed29b..4d0d90e1b --- a/main/xiaozhi-server/Dockerfile +++ b/main/xiaozhi-server/Dockerfile @@ -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"] \ No newline at end of file +CMD ["uv", "run", "app.py"] \ No newline at end of file