mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
62 lines
No EOL
2.1 KiB
Text
Executable file
62 lines
No EOL
2.1 KiB
Text
Executable file
# 第一阶段:前端构建
|
||
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 /app
|
||
|
||
# 优化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 /app/manager/static/webui
|
||
|
||
# 复制应用代码
|
||
COPY . .
|
||
|
||
# 下载模型文件(断点续传 + 自动重试)(如果本没有镜像挂载则取消注释)
|
||
#RUN mkdir -p /app/model/SenseVoiceSmall && \
|
||
# wget -O /app/model/SenseVoiceSmall/model.pt -c --tries=5 --waitretry=5 \
|
||
# https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt
|
||
|
||
# 启动应用
|
||
CMD ["python", "app.py"] |