From 899b5b682b33fd3e17c9b554d15d3bbb03c3fabe Mon Sep 17 00:00:00 2001 From: TOM88812 Date: Tue, 18 Feb 2025 14:56:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=A4=9A=E7=A7=8Ddocker=20build=20?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-pip | 57 ++++++++++++++++++++++++++++++++++++++ docker-compose-example.yml | 11 ++++++-- 2 files changed, 65 insertions(+), 3 deletions(-) create mode 100755 Dockerfile-pip diff --git a/Dockerfile-pip b/Dockerfile-pip new file mode 100755 index 00000000..4eabb69f --- /dev/null +++ b/Dockerfile-pip @@ -0,0 +1,57 @@ +# 第一阶段:前端构建 +FROM node:18 AS frontend-builder + +WORKDIR /app/ZhiKongTaiWeb + +# 配置npm使用淘宝源 +RUN npm config set registry https://registry.npmmirror.com + +COPY ZhiKongTaiWeb/package*.json ./ + +# 安装axios依赖 +RUN npm install axios +RUN npm install + +COPY ZhiKongTaiWeb . + +RUN npm run build + +# 第二阶段:构建Python依赖 +FROM python:3.10-slim AS builder + +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 \ + -i https://pypi.tuna.tsinghua.edu.cn/simple + +# 第三阶段:生产镜像 +FROM python:3.10-slim + +WORKDIR /opt/xiaozhi-esp32-server + +# 优化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 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 --from=frontend-builder /app/ZhiKongTaiWeb/dist /opt/xiaozhi-esp32-server/manager/static/webui + +# 复制应用代码 +COPY . . + +# 启动应用 +CMD ["python", "app.py"] \ No newline at end of file diff --git a/docker-compose-example.yml b/docker-compose-example.yml index 41a4ebf9..ab97b6eb 100755 --- a/docker-compose-example.yml +++ b/docker-compose-example.yml @@ -6,7 +6,12 @@ services: #security_opt: # - seccomp:unconfined ports: - - "8000:8000" - - "8002:8002" + - "8000:8000" # ws服务端 + - "8002:8002" # 管理后台 volumes: - - ./.config.yaml:/opt/xiaozhi-esp32-server/config.yaml \ No newline at end of file + # 配置文件 记得创建文件夹 + - ./data:/opt/xiaozhi-esp32-server/data + # 模型文件 //可以挂载本地下载好的模型 + #- ./models:/opt/xiaozhi-esp32-server/models + # 临时文件 //可以看log和音频文件 记得创建文件夹 + #- ./tmp:/opt/xiaozhi-esp32-server/tmp From ce7f9fce9ac7d7ef10f7969e5c49e96d21c84c6a Mon Sep 17 00:00:00 2001 From: TOM88812 Date: Tue, 18 Feb 2025 15:09:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=EF=BC=9Apush?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0a545fa8..8be615c0 100644 --- a/.gitignore +++ b/.gitignore @@ -143,4 +143,5 @@ tmp .config.yaml .secrets.yaml .private_config.yaml +.env.development docker-compose.yml