From d3bbbfc575c7b13ff030ee7dab5eb3854b54ea94 Mon Sep 17 00:00:00 2001 From: adrian Date: Thu, 16 Apr 2026 21:29:55 +0000 Subject: [PATCH 1/2] Remove chmod -R a+rwX /opt to eliminate ~22GB image layer In Docker/BuildKit, every RUN instruction that modifies existing files creates a new layer containing the full diff of those changes. Running chmod -R on /opt after installing ROCm, PyTorch, vLLM, flash-attention, and bitsandbytes touches every file in the directory, causing the container runtime (overlayfs) to track all of them again in a new layer. This effectively doubles the storage cost of /opt in the final image. Files installed by pip and the ROCm tarball already have appropriate permissions (755 for executables/dirs, 644 for data files). The chmod was redundant and its removal saves ~20GB from the final image size, as confirmed by inspecting layer sizes with podman history. --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 29b006d..076a927 100644 --- a/Dockerfile +++ b/Dockerfile @@ -99,8 +99,7 @@ RUN cmake -S . \ # 8. Final Cleanup & Runtime WORKDIR /opt -RUN chmod -R a+rwX /opt && \ - find /opt/venv -type f -name "*.so" -exec strip -s {} + 2>/dev/null || true && \ +RUN find /opt/venv -type f -name "*.so" -exec strip -s {} + 2>/dev/null || true && \ find /opt/venv -type d -name "__pycache__" -prune -exec rm -rf {} + && \ rm -rf /root/.cache/pip || true && \ dnf clean all && rm -rf /var/cache/dnf/* From 96d8f6480d22a6d634a9d7d5df46a4ba662a29af Mon Sep 17 00:00:00 2001 From: adrian Date: Thu, 16 Apr 2026 22:06:33 +0000 Subject: [PATCH 2/2] Remove second chmod -R a+rwX /opt after RCCL install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The original Dockerfile had two instances of this command — one in the cleanup step (removed previously) and one after the RCCL install. Both create the same oversized layer for the same reason. --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 076a927..60022ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -141,10 +141,8 @@ RUN echo "Installing Custom RCCL..." && \ rm /tmp/librccl.so.1 # 10. Force Upgrade Transformers (User Override) -# Required for GLM Flash, Qwen 3.5 etc.... vLLM reports incompatibility with transformers >= 5, +# Required for GLM Flash, Qwen 3.5 etc.... vLLM reports incompatibility with transformers >= 5, # but this version (5.3.0) has been tested and confirmed working. RUN python -m pip install transformers==5.3.0 -RUN chmod -R a+rwX /opt - CMD ["/bin/bash"]