Files
xiaozhi-esp32-server/Dockerfile
T

45 lines
1.6 KiB
Docker
Raw Permalink Normal View History

# 第一阶段:前端构建
2025-02-18 20:30:03 +08:00
FROM kalicyh/node:v18-alpine AS frontend-builder
WORKDIR /app/ZhiKongTaiWeb
2025-02-18 20:30:03 +08:00
# RUN corepack enable && yarn config set registry https://registry.npmmirror.com
2025-02-17 02:44:05 +08:00
COPY ZhiKongTaiWeb/package.json ZhiKongTaiWeb/yarn.lock ./
2025-02-18 15:46:57 +08:00
RUN yarn install --frozen-lockfile
2025-02-17 02:44:05 +08:00
COPY ZhiKongTaiWeb .
RUN yarn build
2025-02-17 02:44:05 +08:00
# 第二阶段:构建 Python 依赖
2025-02-18 20:30:03 +08:00
FROM kalicyh/poetry:v3.10_xiaozhi AS builder
2025-02-18 15:46:57 +08:00
2025-02-06 11:01:05 +08:00
WORKDIR /app
2025-02-18 15:46:57 +08:00
# 同时拷贝本地环境.venv
COPY . .
# 检查是否有缺失
2025-02-17 19:37:01 +08:00
RUN poetry install --no-root
2025-02-06 11:01:05 +08:00
2025-02-18 15:46:57 +08:00
# 使用清华源加速apt安装,该镜像内置所以注释
# RUN rm -rf /etc/apt/sources.list.d/* && \
# 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 && \
# apt-get clean
2025-02-06 02:08:58 +08:00
# 从构建阶段复制虚拟环境和前端构建产物
2025-02-18 15:46:57 +08:00
COPY --from=frontend-builder /app/ZhiKongTaiWeb/dist /app/manager/static/webui
2025-02-19 01:01:48 +08:00
2025-02-06 11:01:05 +08:00
# 设置虚拟环境路径
2025-02-18 15:46:57 +08:00
ENV PATH="/app/.venv/bin:$PATH"
2025-02-06 11:01:05 +08:00
# 启动应用
2025-02-18 15:46:57 +08:00
ENTRYPOINT ["poetry", "run", "python"]
CMD ["app.py"]