Skip to content

build(container): support non-root runtime execution - #3574

Open
ko3n1g wants to merge 11 commits into
NVIDIA-NeMo:mainfrom
ko3n1g:test/repository-ci-e2e-rl
Open

ko3n1g wants to merge 11 commits into
NVIDIA-NeMo:mainfrom
ko3n1g:test/repository-ci-e2e-rl

Conversation

@ko3n1g

@ko3n1g ko3n1g commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Background / motivation

  • ARC and sandboxed CI mount an immutable source commit at a custom path and run under a non-root UID.
  • The release image currently anchors uv, Python, and build caches below /root, which is not traversable by that runtime identity.
  • OCI security review also requires downloaded build tools to be verified before execution.

What changed

  • Move Python, uv, TRT-LLM wheel, and ccache state to shared /opt paths with ownership applied in the layers that create the data.
  • Add UID/GID 65532, writable source/venv/cache targets, explicit runtime cache variables, and build-time non-root compatibility probes while retaining root as the default runtime identity.
  • Keep HOME absent from the final image config so OCI runtimes derive the correct home from /etc/passwd after a user override.
  • Update CI cache export paths and the ray.sub cache override to the relocated uv cache.
  • Replace the uv installer script with a pinned release archive and verify per-architecture SHA-256 checksums for uv and CMake.

Details

  • Heavy cache ownership is set during creation to avoid duplicating large layers with a later recursive snapshot.
  • Build and cache-export stages continue to run as root; the release image supports --user 65532:65532 and Kubernetes runAsUser: 65532 without changing its default root identity.
  • Both the baked checkout and the custom-source mount path are checked for non-root writes.
  • The final release-stage sync installs the NeMo RL project into /opt/nemo_rl_venv.

Tested

  • docker buildx build --check -f docker/Dockerfile . — completed with no warnings.
  • bash -n ray.sub — passed.
  • git diff --check — passed.
  • pre-commit run --files docker/Dockerfile ray.sub docs/cluster.md — applicable repository check passed.
  • DL/JOC NeMo-CI pipeline 63363213 — running from main-mirror with RL_REF=f0ad0fd15886eb4b7ff3718963f70f06b4e812e4; limited to llm_performance_grpo_llama3_1_8b_instruct_2n8g in the performance suite on cw_dfw.

Pre-checks

  • Read and followed the contributor guidelines.
  • Selected CI:L0 because the container image changes.
  • Full container/GPU proof is running in DL/JOC pipeline 63363213.
  • Dockerfile comments document the runtime ownership and cache contract.

@ko3n1g ko3n1g added the CI:L0 Run doctests and unit tests label Aug 10, 2026
@copy-pr-bot

copy-pr-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the CI Relating to CI label Aug 10, 2026
@ko3n1g
ko3n1g force-pushed the test/repository-ci-e2e-rl branch 4 times, most recently from 8504c3c to c50e1ae Compare August 12, 2026 22:03
@ko3n1g
ko3n1g force-pushed the test/repository-ci-e2e-rl branch from ceb9e48 to e99756e Compare August 14, 2026 22:47
@ko3n1g

ko3n1g commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

@ko3n1g
ko3n1g marked this pull request as ready for review August 17, 2026 18:26
@ko3n1g
ko3n1g requested review from a team as code owners August 17, 2026 18:26

@thomasdhc thomasdhc 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.

Changes requested.

Review notes

  • The build-time non-root probes each export HOME=/home/nemo-runtime themselves, so they do not exercise the home directory a plain --user 65532:65532 invocation actually receives.
  • The release probe now ends with uv sync --frozen --all-groups --no-install-project, so the shipped /opt/nemo_rl_venv no longer carries the project install that the previous uv run prefetch left in place.

Comment thread docker/Dockerfile Resolved
Comment thread docker/Dockerfile Resolved
@copy-pr-bot

copy-pr-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@ko3n1g
ko3n1g requested a review from a team as a code owner August 18, 2026 20:22
@ko3n1g

ko3n1g commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test f0ad0fd

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Aug 18, 2026

@thomasdhc thomasdhc 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.

Review completed.

Review notes

  • The container fingerprint check is unaffected by the ownership move, because tools/generate_fingerprint.py passes an explicit --git-dir and --work-tree and therefore bypasses Git's ownership validation.
  • The pinned uv and CMake archives verify against the upstream published SHA-256 checksums for both x86_64 and aarch64.

Comment thread docker/Dockerfile Resolved
@ko3n1g

ko3n1g commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

@ko3n1g
ko3n1g requested a review from a team as a code owner August 19, 2026 14:28
@ko3n1g

ko3n1g commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test f0c8719

thomasdhc
thomasdhc previously approved these changes Aug 19, 2026

@thomasdhc thomasdhc 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.

LGTM, please address below P2 in a follow-up.

Review notes

  • The relocated uv cache, Python installation directory, and prefetched environments no longer resolve through /root, and the release-stage probes exercise both the baked checkout and the custom-source mount target as the unprivileged UID.
  • Root remains the default runtime identity, and every shipped Git worktree is registered as a system safe directory, so root-run Git commands still work after the source tree moves to the runtime UID.

Comment thread docker/Dockerfile Resolved
@ko3n1g
ko3n1g enabled auto-merge (squash) August 19, 2026 15:10
@ko3n1g
ko3n1g disabled auto-merge August 19, 2026 16:08
Comment thread docker/Dockerfile Resolved
Comment thread docker/Dockerfile Resolved
@kajalj22

kajalj22 commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Two good to haves, not blockers:

  1. Since docs/docker.md is the repo's main "how to build the image" doc but wasn't touched here: could you add a short section on the new RUNTIME_UID/RUNTIME_GID build args and how to actually exercise non-root execution (e.g. docker run --user 65532:65532 / Kubernetes runAsUser: 65532) if you think that is appropriate here? Right now the image still defaults to root, so without docs there's no discoverable way for a user to learn this capability exists.

  2. Nice set of build-time non-root probes. One gap: nothing in cicd-main.yml runs docker run --user 65532:65532 ... against the actual pulled/tagged artifact post-build — the build-time USER switch is a real permission check via BuildKit, but it doesn't cover the final published image or production-like constraints (e.g. readOnlyRootFilesystem, dropped capabilities). Not a blocker, but could be a good CI follow-up.

@terrykong terrykong added CI:L1 Run doctests, unit tests, and functional tests and removed CI:L0 Run doctests and unit tests labels Nov 5, 2026
@terrykong terrykong removed Documentation Improvements or additions to documentation CI Relating to CI labels Nov 28, 2026

This branch has not been deployed

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

Labels

CI:L1 Run doctests, unit tests, and functional tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants