Skip to content

fix(docker): use multi-arch gosu binary for DGX Spark ARM64 support - #879

Closed
kagura-agent wants to merge 2 commits into
NVIDIA:mainfrom
kagura-agent:fix/gosu-multiarch
Closed

fix(docker): use multi-arch gosu binary for DGX Spark ARM64 support#879
kagura-agent wants to merge 2 commits into
NVIDIA:mainfrom
kagura-agent:fix/gosu-multiarch

Conversation

@kagura-agent

@kagura-agent kagura-agent commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix gosu binary architecture detection to support ARM64 platforms (DGX Spark GB10).

Related Issue

Closes #877

Changes

The Dockerfile hardcoded gosu-amd64, causing Exec format error on ARM64:

/bin/sh: 1: gosu: Exec format error

Fix: Use dpkg --print-architecture to select the correct binary at build time and verify the checksum dynamically from the upstream SHA256SUMS file.

Before After
Downloads gosu-amd64 always Downloads gosu-${ARCH} based on platform
Hardcoded amd64 checksum Fetches + verifies from upstream SHA256SUMS

Testing

  • Verified SHA256SUMS file contains checksums for both gosu-amd64 and gosu-arm64
  • amd64 checksum matches the previously hardcoded value (52c8749d...)
  • dpkg --print-architecture returns amd64 or arm64 on respective platforms

Checklist

  • Addresses a single issue
  • Maintains checksum verification (security)
  • No breaking changes for existing amd64 builds
  • Follows PR template format

Summary by CodeRabbit

  • Chores
    • Container build now auto-detects system architecture and selects appropriate artifacts instead of a single hardcoded configuration.
    • Improved security with per-architecture checksum verification for downloaded build dependencies.
    • Builds on unsupported architectures now fail early with a clear error to avoid partial/invalid installs.

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
@coderabbitai

coderabbitai Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The Dockerfile's gosu install is changed to detect the container architecture via dpkg --print-architecture, download the matching gosu release artifact, extract an architecture-specific SHA256 from the upstream SHA256SUMS, verify the binary, and fail early on unsupported architectures.

Changes

Cohort / File(s) Summary
Multi-architecture gosu installation
Dockerfile
Replace hardcoded amd64 gosu download with architecture detection (dpkg --print-architecture), download SHA256SUMS, select per-architecture checksum via case, verify with sha256sum -c, and error/exit on unsupported architectures.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I sniff the Dockerfile, nose twitching with delight,
No more one-size gosu — each arch finds its right bite.
From arm to intel, I bound and I cheer,
Binaries verified, the path now clear! 🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: enabling multi-architecture gosu binary support for ARM64 platforms, which directly addresses the core issue in the changeset.
Linked Issues check ✅ Passed The code changes fully address issue #877's requirements: using architecture detection to select the correct gosu binary and verifying it with per-architecture SHA256 checksums.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the gosu binary architecture selection in the Dockerfile; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b3783dba-398a-40eb-aa00-0cffff30620f

📥 Commits

Reviewing files that changed from the base of the PR and between 95fc7e2 and 9432ac4.

📒 Files selected for processing (1)
  • Dockerfile

Comment thread Dockerfile Outdated
Address CodeRabbit review: dynamic SHA256SUMS fetch weakens
supply-chain immutability. Pin checksums per architecture with
a case statement and fail on unsupported architectures.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 42874729-948f-41ea-b626-6e97062720dd

📥 Commits

Reviewing files that changed from the base of the PR and between 9432ac4 and 30fe111.

📒 Files selected for processing (1)
  • Dockerfile

Comment thread Dockerfile
Comment on lines +29 to +35
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 \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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.

@cr7258

cr7258 commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Duplicated: #861

@prekshivyas

Copy link
Copy Markdown
Collaborator

Closing as duplicate of #861 which was merged at 2026-03-25T12:43:26Z. Both PRs address the same gosu amd64 hardcoding issue with the same approach (dpkg --print-architecture). #861 also includes an arm64 CI build job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dockerfile: gosu binary hardcoded to amd64, breaks DGX Spark (arm64)

4 participants