From 3255c5adb3c99937aa66ad0e314bd8af0c73b020 Mon Sep 17 00:00:00 2001 From: SZCJW <792430652@qq.com> Date: Sun, 15 Mar 2026 22:56:20 +0800 Subject: [PATCH] x --- Dockerfile | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4eafab1..f5636b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,10 +46,26 @@ RUN dnf -y install --setopt=install_weak_deps=False --nodocs \ WORKDIR /tmp ARG ROCM_MAJOR_VER=7 ARG GFX=gfx120X-all -COPY therock.tar.gz /tmp/therock.tar.gz -RUN mkdir -p /opt/rocm && \ - tar xzf therock.tar.gz -C /opt/rocm --strip-components=1 && \ - rm therock.tar.gz + +# 智能处理:如果 build context 里有 therock.tar.gz 就用本地的,没有就从网络拉取 +# 注意:Dockerfile 的 COPY 无法直接做条件判断,我们通过 shell 逻辑处理 +RUN set -euo pipefail; \ + if [ -f "therock.tar.gz" ]; then \ + echo "Using local therock.tar.gz from build context."; \ + else \ + echo "Local SDK not found, downloading from remote..."; \ + BASE="https://therock-nightly-tarball.s3.amazonaws.com"; \ + PREFIX="therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}"; \ + KEY="$(maybe_proxy curl -s "${BASE}?list-type=2&prefix=${PREFIX}" \ + | tr '<' '\n' \ + | grep -o "therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}\..*\.tar\.gz" \ + | sort -V | tail -n1)"; \ + echo "Downloading Latest Tarball: ${KEY}"; \ + maybe_proxy aria2c -x 16 -s 16 -k 1M --file-allocation=none "${BASE}/${KEY}" -o therock.tar.gz; \ + fi && \ + mkdir -p /opt/rocm && \ + tar xzf therock.tar.gz -C /opt/rocm --strip-components=1 && \ + rm therock.tar.gz # 3. Configure Global ROCm Environment RUN export ROCM_PATH=/opt/rocm && \