fix(docker): use multi-arch gosu binary for DGX Spark ARM64 support - #879
fix(docker): use multi-arch gosu binary for DGX Spark ARM64 support#879kagura-agent wants to merge 2 commits into
Conversation
The Dockerfile hardcoded gosu-amd64, which fails on ARM64 platforms like DGX Spark (GB10, aarch64) with 'Exec format error'. Use dpkg --print-architecture to select the correct binary at build time and verify the checksum from the upstream SHA256SUMS file. Fixes NVIDIA#877
📝 WalkthroughWalkthroughThe Dockerfile's gosu install is changed to detect the container architecture via Changes
Sequence Diagram(s)sequenceDiagram
participant Builder as Builder (docker build)
participant Dockerfile as Dockerfile RUN
participant GitHub as GitHub Releases
participant Verifier as sha256sum
Builder->>Dockerfile: execute gosu install step
Dockerfile->>Dockerfile: detect arch (`dpkg --print-architecture`)
Dockerfile->>GitHub: curl SHA256SUMS and gosu-${ARCH}
GitHub-->>Dockerfile: return SHA256SUMS, gosu-${ARCH}
Dockerfile->>Verifier: extract expected checksum for ${ARCH}
Dockerfile->>Verifier: run `sha256sum -c` on downloaded gosu
Verifier-->>Dockerfile: verification result
alt verified
Dockerfile->>Dockerfile: chmod +x /usr/local/bin/gosu
else failed / unsupported
Dockerfile-->>Builder: exit non-zero with error
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Dockerfile`:
- Around line 29-33: The Dockerfile currently downloads the gosu binary and a
dynamic SHA256SUMS file (variables/targets: GOSU_ARCH, /usr/local/bin/gosu,
/tmp/gosu-sha256sums) which weakens supply-chain immutability; replace the
runtime fetch-and-grep of SHA256SUMS with a per-architecture pinned checksum
lookup using the provided v1.19 hashes (amd64: 52c8749d..., arm64: 3a8ef022...),
verify the downloaded /usr/local/bin/gosu against the matching pinned hash, and
optionally add GPG signature verification using the release key
B42F6819007F00F88E364FD4036A9C25BF357DD4 for defense-in-depth.
Address CodeRabbit review: dynamic SHA256SUMS fetch weakens supply-chain immutability. Pin checksums per architecture with a case statement and fail on unsupported architectures.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Dockerfile`:
- Around line 29-35: The RUN block currently sets GOSU_ARCH and calls curl
before validating the architecture; move the architecture allowlist check (the
case on GOSU_ARCH that sets GOSU_SHA256 or errors) to run immediately after
GOSU_ARCH is set and before invoking curl so unsupported architectures fail
fast; specifically, evaluate GOSU_ARCH with the case statement first (to set
GOSU_SHA256 or exit on unsupported arch) and only then run curl to download the
gosu binary.
| RUN GOSU_ARCH="$(dpkg --print-architecture)" \ | ||
| && curl -fsSL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.19/gosu-${GOSU_ARCH}" \ | ||
| && case "${GOSU_ARCH}" in \ | ||
| amd64) GOSU_SHA256="52c8749d0142edd234e9d6bd5237dff2d81e71f43537e2f4f66f75dd4b243dd0" ;; \ | ||
| arm64) GOSU_SHA256="3a8ef022d82c0bc4a98bcb144e77da714c25fcfa64dccc57f6aba7ae47ff1a44" ;; \ | ||
| *) echo "Unsupported architecture: ${GOSU_ARCH}" >&2; exit 1 ;; \ | ||
| esac \ |
There was a problem hiding this comment.
Move the architecture allowlist check before curl to actually fail early.
Right now, Line 30 downloads first and only then Line 31 validates architecture. On unsupported architectures, the build can fail at curl before reaching your explicit error path.
Suggested reorder
RUN GOSU_ARCH="$(dpkg --print-architecture)" \
- && curl -fsSL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.19/gosu-${GOSU_ARCH}" \
&& case "${GOSU_ARCH}" in \
amd64) GOSU_SHA256="52c8749d0142edd234e9d6bd5237dff2d81e71f43537e2f4f66f75dd4b243dd0" ;; \
arm64) GOSU_SHA256="3a8ef022d82c0bc4a98bcb144e77da714c25fcfa64dccc57f6aba7ae47ff1a44" ;; \
*) echo "Unsupported architecture: ${GOSU_ARCH}" >&2; exit 1 ;; \
esac \
+ && curl -fsSL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.19/gosu-${GOSU_ARCH}" \
&& echo "${GOSU_SHA256} /usr/local/bin/gosu" | sha256sum -c - \📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| RUN GOSU_ARCH="$(dpkg --print-architecture)" \ | |
| && curl -fsSL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.19/gosu-${GOSU_ARCH}" \ | |
| && case "${GOSU_ARCH}" in \ | |
| amd64) GOSU_SHA256="52c8749d0142edd234e9d6bd5237dff2d81e71f43537e2f4f66f75dd4b243dd0" ;; \ | |
| arm64) GOSU_SHA256="3a8ef022d82c0bc4a98bcb144e77da714c25fcfa64dccc57f6aba7ae47ff1a44" ;; \ | |
| *) echo "Unsupported architecture: ${GOSU_ARCH}" >&2; exit 1 ;; \ | |
| esac \ | |
| RUN GOSU_ARCH="$(dpkg --print-architecture)" \ | |
| && case "${GOSU_ARCH}" in \ | |
| amd64) GOSU_SHA256="52c8749d0142edd234e9d6bd5237dff2d81e71f43537e2f4f66f75dd4b243dd0" ;; \ | |
| arm64) GOSU_SHA256="3a8ef022d82c0bc4a98bcb144e77da714c25fcfa64dccc57f6aba7ae47ff1a44" ;; \ | |
| *) echo "Unsupported architecture: ${GOSU_ARCH}" >&2; exit 1 ;; \ | |
| esac \ | |
| && curl -fsSL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.19/gosu-${GOSU_ARCH}" \ | |
| && echo "${GOSU_SHA256} /usr/local/bin/gosu" | sha256sum -c - |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@Dockerfile` around lines 29 - 35, The RUN block currently sets GOSU_ARCH and
calls curl before validating the architecture; move the architecture allowlist
check (the case on GOSU_ARCH that sets GOSU_SHA256 or errors) to run immediately
after GOSU_ARCH is set and before invoking curl so unsupported architectures
fail fast; specifically, evaluate GOSU_ARCH with the case statement first (to
set GOSU_SHA256 or exit on unsupported arch) and only then run curl to download
the gosu binary.
|
Duplicated: #861 |
Summary
Fix gosu binary architecture detection to support ARM64 platforms (DGX Spark GB10).
Related Issue
Closes #877
Changes
The Dockerfile hardcoded
gosu-amd64, causingExec format erroron ARM64:Fix: Use
dpkg --print-architectureto select the correct binary at build time and verify the checksum dynamically from the upstream SHA256SUMS file.gosu-amd64alwaysgosu-${ARCH}based on platformTesting
gosu-amd64andgosu-arm6452c8749d...)dpkg --print-architecturereturnsamd64orarm64on respective platformsChecklist
Summary by CodeRabbit