Repository navigation
fix: use npm ci with package-lock.json in Dockerfile - #640
webdevpraveen wants to merge 4 commits into
Conversation
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]>
📝 WalkthroughWalkthroughThe Dockerfile now copies both Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Flagging for maintainer review - happy to address any feedback. |
|
Thanks for the proposed fix to ensure consistent dependency versions in the Docker image by including package-lock.json in the Dockerfile. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Dockerfile (1)
5-8: Consider applying the same lockfile-driven install to the builder stage.The builder stage still uses
npm installwithoutpackage-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.
Problem
The runtime stage in
Dockerfilecopiesnemoclaw/package.jsonintothe image but omits
nemoclaw/package-lock.json, then runsnpm install --omit=dev.Without the lockfile,
npm installresolves dependencies from theregistry at build time. Two
docker buildruns from the same Gitcommit can produce images with different transitive dependency versions
if any upstream package is updated between runs — non-reproducible
builds.
Fix
nemoclaw/package-lock.jsoninto the image — it exists inthe repo but was never passed to Docker.
npm installwithnpm ci— reads the lockfileexclusively, installs exactly pinned versions, and exits non-zero if
package.jsonandpackage-lock.jsondrift out of sync.The
RUN npm install -g [email protected]global install line isintentionally unchanged — it installs a pinned external package and
does not use a local lockfile.
References
Summary by CodeRabbit