From b91246ffc596505f9557f159570cb17a3139ce3c Mon Sep 17 00:00:00 2001 From: infinitycat Date: Fri, 7 Nov 2025 09:03:33 +0800 Subject: [PATCH] =?UTF-8?q?test(docker):=20=E5=88=86=E6=AE=B5=E6=9E=84?= =?UTF-8?q?=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 2 +- Dockerfile | 36 +++++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.dockerignore b/.dockerignore index a81a6821..15c09fbf 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,4 +7,4 @@ mongodb napcat docs/ .github/ -# test +# test \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 10b2681d..dafcd281 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,23 @@ -FROM python:3.13.7-slim-trixie +# 编译 LPMM +FROM python:3.13-slim AS lpmm-builder +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ + +WORKDIR /MaiMBot-LPMM + +# 同级目录下需要有 MaiMBot-LPMM +COPY MaiMBot-LPMM /MaiMBot-LPMM + +# 安装编译器和编译依赖 +RUN apt-get update && apt-get install -y build-essential +RUN uv pip install --system --upgrade pip +RUN cd /MaiMBot-LPMM && uv pip install --system -r requirements.txt +RUN uv pip install --system Cython py-cpuinfo setuptools + +# 编译 LPMM +RUN cd /MaiMBot-LPMM/lib/quick_algo && python build_lib.py --cleanup --cythonize --install + +# 运行环境 +FROM python:3.13-slim COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ # 工作目录 @@ -6,20 +25,11 @@ WORKDIR /MaiMBot # 复制依赖列表 COPY requirements.txt . -# 同级目录下需要有 MaiMBot-LPMM -COPY MaiMBot-LPMM /MaiMBot-LPMM -# 编译器 -RUN apt-get update && apt-get install -y build-essential -RUN uv pip install --system --upgrade pip +# 从编译阶段复制 LPMM 编译结果 +COPY --from=lpmm-builder /usr/local/lib/python3.13/site-packages/ /usr/local/lib/python3.13/site-packages/ -# lpmm编译安装 -RUN cd /MaiMBot-LPMM && uv pip install --system -r requirements.txt -RUN uv pip install --system Cython py-cpuinfo setuptools -RUN cd /MaiMBot-LPMM/lib/quick_algo && python build_lib.py --cleanup --cythonize --install - - -# 安装依赖 +# 安装运行时依赖 RUN uv pip install --system -r requirements.txt # 复制项目代码