mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 00:53:54 +08:00
fix: 多种docker build 编译方式
This commit is contained in:
Executable
+57
@@ -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"]
|
||||||
@@ -6,7 +6,12 @@ services:
|
|||||||
#security_opt:
|
#security_opt:
|
||||||
# - seccomp:unconfined
|
# - seccomp:unconfined
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000" # ws服务端
|
||||||
- "8002:8002"
|
- "8002:8002" # 管理后台
|
||||||
volumes:
|
volumes:
|
||||||
- ./.config.yaml:/opt/xiaozhi-esp32-server/config.yaml
|
# 配置文件 记得创建文件夹
|
||||||
|
- ./data:/opt/xiaozhi-esp32-server/data
|
||||||
|
# 模型文件 //可以挂载本地下载好的模型
|
||||||
|
#- ./models:/opt/xiaozhi-esp32-server/models
|
||||||
|
# 临时文件 //可以看log和音频文件 记得创建文件夹
|
||||||
|
#- ./tmp:/opt/xiaozhi-esp32-server/tmp
|
||||||
|
|||||||
Reference in New Issue
Block a user