diff --git a/.idea/MarsCodeWorkspaceAppSettings.xml b/.idea/MarsCodeWorkspaceAppSettings.xml deleted file mode 100644 index e2a065b..0000000 --- a/.idea/MarsCodeWorkspaceAppSettings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 62aadda..4294106 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,8 +11,8 @@ ARG PYTHON_VER=3.12 ARG VENV=/opt/mineru_venv ARG TORCH_INDEX=https://download.pytorch.org/whl/rocm7.2 -# -- GitHub 访问(国内无镜像,需代理)---------------------------------------- -ARG GIT_PROXY=http://127.0.0.1:8118 +# -- GitHub 访问(国内无镜像,需代理;默认不走代理)----------------------------- +ARG GIT_PROXY= # -- 国内镜像 ---------------------------------------------------------------- ARG PIP_INDEX=https://mirrors.aliyun.com/pypi/simple @@ -82,13 +82,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # =========================================================================== # 阶段 4:CMake 4.0(通过代理下载加速) # =========================================================================== -RUN export http_proxy=${GIT_PROXY} https_proxy=${GIT_PROXY} && \ +RUN set -ex && \ + CMAKE_TGZ=cmake-4.0.0-linux-x86_64.tar.gz && \ + CMAKE_DIR=cmake-4.0.0-linux-x86_64 && \ + CMAKE_URLS="https://github.com/Kitware/CMake/releases/download/v4.0.0/${CMAKE_TGZ} https://ghproxy.com/https://github.com/Kitware/CMake/releases/download/v4.0.0/${CMAKE_TGZ}" && \ + if [ -n "${GIT_PROXY}" ]; then export http_proxy=${GIT_PROXY} https_proxy=${GIT_PROXY}; fi && \ cd /tmp && \ - wget -q https://github.com/Kitware/CMake/releases/download/v4.0.0/cmake-4.0.0-linux-x86_64.tar.gz && \ - tar -xzf cmake-4.0.0-linux-x86_64.tar.gz && \ - cp -r cmake-4.0.0-linux-x86_64/bin/* /usr/local/bin/ && \ - cp -r cmake-4.0.0-linux-x86_64/share/* /usr/local/share/ && \ - rm -rf cmake-4.0.0-linux-x86_64* && \ + ok=0; \ + for url in ${CMAKE_URLS}; do \ + echo "Downloading CMake from: ${url}"; \ + if curl -fL --retry 5 --retry-delay 3 --connect-timeout 20 -o ${CMAKE_TGZ} "${url}"; then \ + ok=1; \ + break; \ + fi; \ + done; \ + [ "${ok}" = "1" ] || (echo "Failed to download ${CMAKE_TGZ} from all mirrors" && exit 4) && \ + tar -xzf ${CMAKE_TGZ} && \ + cp -r ${CMAKE_DIR}/bin/* /usr/local/bin/ && \ + cp -r ${CMAKE_DIR}/share/* /usr/local/share/ && \ + rm -rf ${CMAKE_TGZ} ${CMAKE_DIR} && \ cmake --version # =========================================================================== diff --git a/docker/README.md b/docker/README.md index 93aed3d..cd4b629 100644 --- a/docker/README.md +++ b/docker/README.md @@ -163,6 +163,7 @@ cp env.example .env # 方式一:docker build(直接指定 ARCH) docker build \ --build-arg ARCH=gfx1201 \ + --build-arg GIT_PROXY= \ -t mineru-rocm:7.2.1 \ -f Dockerfile . @@ -186,6 +187,7 @@ docker compose build | `PYTHON_VER` | `3.12` | Python 版本 | | `VENV` | `/opt/mineru_venv` | 虚拟环境路径 | | `TORCH_INDEX` | `https://download.pytorch.org/whl/rocm7.2` | PyTorch wheel 源 | +| `GIT_PROXY` | 空 | 仅构建时访问 GitHub 用;例如 `http://host.docker.internal:8118` | --- @@ -446,6 +448,21 @@ docker compose restart gradio 内存不足。将 Dockerfile 中 `ninja -j4` 改为 `ninja -j2` 或 `ninja -j1`,或给 Docker 分配更多内存。 +**Q: 构建在 CMake 下载阶段失败(`wget/curl exit code 4`)** + +这通常是构建容器无法访问 GitHub,或把 `GIT_PROXY` 设成了容器内不可达地址(例如 `127.0.0.1:8118` 在多数 Docker 场景下指向容器自己,不是宿主机代理)。建议: + +1. 不需要代理时,显式传空:`--build-arg GIT_PROXY=` +2. 需要宿主机代理时,优先用:`http://host.docker.internal:8118` +3. 先单独测试下载连通性,再完整构建 + +```bash +docker build --build-arg GIT_PROXY= -t mineru-rocm:7.2.1 -f Dockerfile . + +# 或(宿主机代理) +docker build --build-arg GIT_PROXY=http://host.docker.internal:8118 -t mineru-rocm:7.2.1 -f Dockerfile . +``` + **Q: 构建时 cmake 报 `Failed to find ROCm root directory`** `/opt/rocm/bin` 不在 PATH 中。检查 Dockerfile 中 `ENV PATH` 是否正确设置。 diff --git a/docker/env.example b/docker/env.example index a36a49f..0baec63 100644 --- a/docker/env.example +++ b/docker/env.example @@ -9,6 +9,10 @@ # gfx1030 = RX 6950 / 6900 / 6800 系列 ARCH=gfx1201 +# ---- 可选:构建阶段 GitHub 下载代理(不需要可留空)---- +# 示例: GIT_PROXY=http://host.docker.internal:8118 +GIT_PROXY= + # ---- 目录挂载 ---- INPUT_DIR=./data/input OUTPUT_DIR=./data/output