From 177c508da037cc7d71c580ad9ba1845cc2432571 Mon Sep 17 00:00:00 2001 From: chenjw28 <792430652@qq.com> Date: Wed, 10 Jun 2026 15:14:00 +0800 Subject: [PATCH] x --- docker/Dockerfile | 12 +++++------- docker/docker-compose.yml | 4 ++++ docker/scripts/entrypoint.sh | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 docker/scripts/entrypoint.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index 8641a08..1b9d312 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -267,11 +267,11 @@ RUN set -ex && \ echo "vllm C++ build complete (layer cached)." # =========================================================================== -# 阶段 7.5:复制辅助脚本(必须在所有使用脚本的 RUN 之前) +# 阶段 7.5:复制入口 + 辅助脚本 # =========================================================================== -COPY scripts/patch_vllm_platform.py /opt/patch_vllm_platform.py -COPY scripts/apply_mineru_patches.py /opt/apply_mineru_patches.py -COPY scripts/cache_warmer.py /opt/cache_warmer.py +COPY scripts/entrypoint.sh /opt/entrypoint.sh +RUN chmod +x /opt/entrypoint.sh +COPY scripts/cache_warmer.py /opt/scripts/cache_warmer.py # =========================================================================== # 阶段 8b:安装 vllm + 平台补丁 + 验证 @@ -279,7 +279,6 @@ COPY scripts/cache_warmer.py /opt/cache_warmer.py RUN set -ex && \ cd /opt/vllm && ${VENV}/bin/pip install -e . --no-build-isolation && \ ${VENV}/bin/pip install regex && \ - ${VENV}/bin/python /opt/patch_vllm_platform.py && \ ${VENV}/bin/python -c "import torch; v=torch.__version__; assert 'rocm' in v, f'PyTorch overwritten: {v}'; print('PyTorch OK:', v)" && \ ${VENV}/bin/pip uninstall -y triton triton-rocm 2>/dev/null; \ ${VENV}/bin/pip install --force-reinstall \ @@ -293,7 +292,6 @@ RUN set -ex && \ # =========================================================================== RUN set -ex && \ ${VENV}/bin/pip install 'mineru[core]' && \ - ${VENV}/bin/python /opt/apply_mineru_patches.py && \ # mineru[core] 会把 ROCm PyTorch 替换成 CUDA 版 + 安装 CUDA triton # 必须先卸载 CUDA triton,再装回 ROCm 版 ${VENV}/bin/pip uninstall -y triton triton-rocm 2>/dev/null; \ @@ -310,5 +308,5 @@ RUN set -ex && \ RUN echo 'source /opt/mineru_venv/bin/activate' >> /etc/bash.bashrc && \ ${VENV}/bin/python -c "import torch; import vllm; import mineru; print('MinerU ROCm Docker Image Ready'); print(f'PyTorch {torch.__version__} OK')" -ENTRYPOINT ["/bin/bash", "-c"] +ENTRYPOINT ["/opt/entrypoint.sh"] CMD ["bash"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b143dea..ebdd014 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -23,6 +23,7 @@ services: - ${INPUT_DIR:-./data/input}:/data/input:ro - ${OUTPUT_DIR:-./data/output}:/data/output - ${MODEL_DIR:-./data/models}:/opt/models + - ./scripts:/opt/scripts:ro command: [ "mineru-gradio", @@ -64,6 +65,7 @@ services: - ${OUTPUT_DIR:-./data/output}:/data/output - ${MODEL_DIR:-./data/models}:/opt/models - ${MIOPEN_CACHE:-./data/miopen}:/root/.cache/miopen + - ./scripts:/opt/scripts:ro command: ["mineru-api", "--host", "0.0.0.0", "--port", "8001"] worker1: @@ -89,6 +91,7 @@ services: - ${OUTPUT_DIR:-./data/output}:/data/output - ${MODEL_DIR:-./data/models}:/opt/models - ${MIOPEN_CACHE:-./data/miopen}:/root/.cache/miopen + - ./scripts:/opt/scripts:ro command: ["mineru-api", "--host", "0.0.0.0", "--port", "8002"] router: @@ -104,6 +107,7 @@ services: volumes: - ${INPUT_DIR:-./data/input}:/data/input:ro - ${OUTPUT_DIR:-./data/output}:/data/output + - ./scripts:/opt/scripts:ro command: [ "mineru-router", diff --git a/docker/scripts/entrypoint.sh b/docker/scripts/entrypoint.sh new file mode 100644 index 0000000..8bec7f8 --- /dev/null +++ b/docker/scripts/entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# ============================================================================= +# MinerU ROCm 统一入口 — 启动时执行补丁,然后启动指定服务 +# ============================================================================= +set -e + +VENV=/opt/mineru_venv +SCRIPTS_DIR=/opt/scripts + +echo "[entrypoint] running patches..." + +# vllm 平台补丁 +if [ -f ${SCRIPTS_DIR}/patch_vllm_platform.py ]; then + ${VENV}/bin/python ${SCRIPTS_DIR}/patch_vllm_platform.py || echo "[entrypoint] patch_vllm_platform.py failed (non-fatal)" +fi + +# MinerU 推理补丁 +if [ -f ${SCRIPTS_DIR}/apply_mineru_patches.py ]; then + ${VENV}/bin/python ${SCRIPTS_DIR}/apply_mineru_patches.py || echo "[entrypoint] apply_mineru_patches.py failed (non-fatal)" +fi + +echo "[entrypoint] starting: $*" +exec "$@"