Skip to content

fix: use npm ci with package-lock.json in Dockerfile - #640

Closed
webdevpraveen wants to merge 4 commits into
NVIDIA:mainfrom
webdevpraveen:fix/dockerfile-use-npm-ci-with-lockfile
Closed

webdevpraveen wants to merge 4 commits into
NVIDIA:mainfrom
webdevpraveen:fix/dockerfile-use-npm-ci-with-lockfile

Conversation

@webdevpraveen

@webdevpraveen webdevpraveen commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The runtime stage in Dockerfile copies nemoclaw/package.json into
the image but omits nemoclaw/package-lock.json, then runs
npm install --omit=dev.

Without the lockfile, npm install resolves dependencies from the
registry at build time. Two docker build runs from the same Git
commit can produce images with different transitive dependency versions
if any upstream package is updated between runs — non-reproducible
builds
.

Fix

-COPY nemoclaw/package.json /opt/nemoclaw/
+COPY nemoclaw/package.json nemoclaw/package-lock.json /opt/nemoclaw/

-RUN npm install --omit=dev
+RUN npm ci --omit=dev
  1. Copy nemoclaw/package-lock.json into the image — it exists in
    the repo but was never passed to Docker.
  2. Replace npm install with npm ci — reads the lockfile
    exclusively, installs exactly pinned versions, and exits non-zero if
    package.json and package-lock.json drift out of sync.

The RUN npm install -g [email protected] global install line is
intentionally unchanged — it installs a pinned external package and
does not use a local lockfile.

References

Summary by CodeRabbit

  • Chores
    • Runtime image now installs dependencies deterministically using the project's lockfile (still excluding dev dependencies), improving reproducibility and build consistency for deployed releases.

The runtime stage copies nemoclaw/package.json into /opt/nemoclaw/
but omits nemoclaw/package-lock.json, then runs 'npm install --omit=dev'.

Without the lockfile npm resolves dependencies from the registry at
build time. Two docker builds from the same Git commit can install
different transitive dependency versions if any package is updated
between runs — producing non-reproducible images.

Fix: copy nemoclaw/package-lock.json alongside package.json and
replace 'npm install' with 'npm ci'. npm ci reads the lockfile,
installs exactly the pinned versions, and fails fast if package.json
and package-lock.json drift out of sync.

Signed-off-by: Praveen Singh <[email protected]>
@coderabbitai

coderabbitai Bot commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The Dockerfile now copies both package.json and package-lock.json into /opt/nemoclaw/ and replaces npm install --omit=dev with npm ci --omit=dev, enabling lockfile-driven, deterministic installs while still omitting devDependencies.

Changes

Cohort / File(s) Summary
Docker Configuration
Dockerfile
Adds package-lock.json to the COPY step and replaces npm install --omit=dev with npm ci --omit=dev to perform lockfile-driven installs at runtime.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped into the build today,
A lockfile tucked beneath my paw,
npm ci leads the steady way,
No drifting versions to withdraw.
Reproducible hops — hooray!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: switching from npm install to npm ci and including package-lock.json in the Dockerfile for reproducible builds.
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.

@webdevpraveen

Copy link
Copy Markdown
Contributor Author

Flagging for maintainer review - happy to address any feedback.

@wscurran

Copy link
Copy Markdown
Contributor

Thanks for the proposed fix to ensure consistent dependency versions in the Docker image by including package-lock.json in the Dockerfile.

Charjags

This comment was marked as off-topic.

cjagwani

This comment was marked as outdated.

@cjagwani
cjagwani dismissed Charjags’s stale review March 25, 2026 17:08

my private account

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

🧹 Nitpick comments (1)
Dockerfile (1)

5-8: Consider applying the same lockfile-driven install to the builder stage.

The builder stage still uses npm install without package-lock.json, meaning devDependencies (TypeScript, build tools) could vary between builds. For full reproducibility, consider updating the builder stage as well:

♻️ Proposed changes for builder stage
-COPY nemoclaw/package.json nemoclaw/tsconfig.json /opt/nemoclaw/
+COPY nemoclaw/package.json nemoclaw/package-lock.json nemoclaw/tsconfig.json /opt/nemoclaw/
 COPY nemoclaw/src/ /opt/nemoclaw/src/
 WORKDIR /opt/nemoclaw
-RUN npm install && npm run build
+RUN npm ci && npm run build
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Dockerfile` around lines 5 - 8, The builder stage in the Dockerfile currently
runs "RUN npm install && npm run build" using only package.json, so
devDependencies used for building can vary; update the builder stage to copy the
lockfile (package-lock.json) alongside package.json/tsconfig.json before
installation and replace "npm install" with a lockfile-driven install (e.g.,
"npm ci") so the build uses pinned devDependencies—look for the COPY line that
copies "nemoclaw/package.json nemoclaw/tsconfig.json /opt/nemoclaw/" and the RUN
line "npm install && npm run build" and modify them to include the lockfile and
use npm ci.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Dockerfile`:
- Around line 5-8: The builder stage in the Dockerfile currently runs "RUN npm
install && npm run build" using only package.json, so devDependencies used for
building can vary; update the builder stage to copy the lockfile
(package-lock.json) alongside package.json/tsconfig.json before installation and
replace "npm install" with a lockfile-driven install (e.g., "npm ci") so the
build uses pinned devDependencies—look for the COPY line that copies
"nemoclaw/package.json nemoclaw/tsconfig.json /opt/nemoclaw/" and the RUN line
"npm install && npm run build" and modify them to include the lockfile and use
npm ci.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3b08f8ae-785c-407d-8ccd-0548e79f1fe6

📥 Commits

Reviewing files that changed from the base of the PR and between 8a63674 and de2eb33.

📒 Files selected for processing (1)
  • Dockerfile

@cv cv closed this Mar 30, 2026
@wscurran wscurran mentioned this pull request Mar 31, 2026
2 tasks done
@wscurran wscurran added area: packaging Packages, images, registries, installers, or distribution bug-fix PR fixes a bug or regression platform: container Affects Docker, containerd, Podman, or images and removed Docker labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: packaging Packages, images, registries, installers, or distribution bug-fix PR fixes a bug or regression platform: container Affects Docker, containerd, Podman, or images

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants