v0.1.5
parent
b36d1b6bcb
commit
924f5452d2
|
|
@ -18,13 +18,21 @@ RUN python -m venv /opt/venv
|
|||
|
||||
WORKDIR /app
|
||||
COPY pyproject.toml README.md LICENSE THIRD_PARTY_NOTICES.md ./
|
||||
|
||||
# 3. 先安装第三方依赖。该层只依赖 pyproject.toml,源码改动不会触发整套依赖重装。
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
python -m pip install -i https://mirrors.aliyun.com/pypi/simple/ --upgrade \
|
||||
--no-compile pip setuptools wheel aiohttp hatchling && \
|
||||
python -c 'import tomllib; data=tomllib.load(open("pyproject.toml","rb")); deps=list(data["project"].get("dependencies", [])); deps.extend(data["project"].get("optional-dependencies", {}).get("wecom", [])); print("\n".join(deps))' > /tmp/requirements.txt && \
|
||||
pip install --no-compile -i https://mirrors.aliyun.com/pypi/simple/ -r /tmp/requirements.txt && \
|
||||
rm -f /tmp/requirements.txt
|
||||
|
||||
COPY nanobot/ nanobot/
|
||||
COPY bridge/ bridge/
|
||||
|
||||
# 3. 在 builder 中完成 Python 依赖安装,避免源码和编译工具进入最终镜像
|
||||
RUN python -m pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ --upgrade \
|
||||
--no-compile pip setuptools wheel aiohttp && \
|
||||
pip install --no-cache-dir --no-compile -i https://mirrors.aliyun.com/pypi/simple/ ".[wecom]" && \
|
||||
# 4. 源码层只安装 nanobot 本体,不重复解析/下载第三方依赖。
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
pip install --no-compile --no-deps --no-build-isolation . && \
|
||||
find /opt/venv -type d -name __pycache__ -prune -exec rm -rf {} + && \
|
||||
find /opt/venv -name '*.pyc' -delete
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ build_image() {
|
|||
echo ">> [2/3] 拷贝 dashboard.py 到 channels 目录 ..."
|
||||
if [ -d "${BASE_DIR}/${dir_name}/nanobot/channels" ]; then
|
||||
cp "${BASE_DIR}/dashboard.py" "${BASE_DIR}/${dir_name}/nanobot/channels/"
|
||||
elif [ -d "${BASE_DIR}/${dir_name}/channels" ]; then
|
||||
cp "${BASE_DIR}/dashboard.py" "${BASE_DIR}/${dir_name}/channels/"
|
||||
else
|
||||
# 兜底创建 nanobot/channels/
|
||||
mkdir -p "${BASE_DIR}/${dir_name}/nanobot/channels/"
|
||||
|
|
@ -32,7 +30,7 @@ build_image() {
|
|||
# 3. 执行 Docker build
|
||||
echo ">> [3/3] 开始打包 Docker 镜像: ${image_name} ..."
|
||||
cd "${BASE_DIR}/${dir_name}"
|
||||
docker build -f Dashboard.Dockerfile -t "${image_name}" .
|
||||
DOCKER_BUILDKIT=1 docker build -f Dashboard.Dockerfile -t "${image_name}" .
|
||||
|
||||
echo "=================================================="
|
||||
echo "✅ 构建完成: ${image_name}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue