Skip to content

fix(docker): [URGENT] Docker build fails for all PRs - missing web/scripts/prepare.js during npm install - #16821

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
ondery:fix/docker-web-prepare-script
Jul 10, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
ondery:fix/docker-web-prepare-script

Conversation

@ondery

@ondery ondery commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

🚨 Urgent: this breaks the Docker image build for every open PR

The ragflow_tests_elasticsearch and ragflow_tests_infinity jobs — which build the image before running tests — currently fail on all pull requests, not just this one. CI is effectively red repo-wide until this lands. Please review and merge ASAP.

Example failing runs (from an unrelated PR):

Symptom

Error: Cannot find module '/ragflow/web/scripts/prepare.js'
npm error command sh -c node scripts/prepare.js
ERROR: process "/bin/bash -c cd web && NODE_OPTIONS=..." did not complete successfully: exit code: 1

Root cause

web/package.json defines:

"prepare": "node scripts/prepare.js"

npm runs the prepare lifecycle script during npm install. But the frontend-deps layer in the Dockerfile only copies the package manifests before installing:

COPY web/package.json web/package-lock.json web/.npmrc ./web/
RUN ... cd web && npm install     # runs `node scripts/prepare.js` → file not present yet

Since web/scripts/prepare.js is not in the image at that point, npm install aborts and the whole build fails.

Fix

Copy web/scripts before npm install so the prepare script is present:

COPY web/package.json web/package-lock.json web/.npmrc ./web/
COPY web/scripts ./web/scripts
RUN ... cd web && npm install
  • Minimal and safe: scripts/prepare.js only installs lefthook git hooks and already no-ops (wrapped in try/catch) inside the image where there is no Git repo.
  • Preferred over --ignore-scripts, which would also disable dependencies' legitimate install scripts.
  • web/scripts changes rarely, so build-cache impact on this layer is negligible.

Verification

Build reaches the frontend npm install step without the MODULE_NOT_FOUND error. No application code is touched — this is a build-infrastructure fix only.

…ists

The web `prepare` lifecycle script runs `node scripts/prepare.js` during
`npm install`, but the frontend-deps layer only copied the package
manifests. The build failed with "Cannot find module
web/scripts/prepare.js", breaking the image build for every PR.

Copy web/scripts before npm install so the prepare script is present.
Copilot AI review requested due to automatic review settings July 10, 2026 11:10
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 37e91906-6201-4296-b962-1008d951b261

📥 Commits

Reviewing files that changed from the base of the PR and between 2a83ad6 and d52ddf8.

📒 Files selected for processing (1)
  • Dockerfile

📝 Walkthrough

Walkthrough

The Dockerfile builder stage now copies web/scripts before running npm install, ensuring web/scripts/prepare.js is available during the prepare lifecycle step.

Changes

Frontend build preparation

Layer / File(s) Summary
Copy scripts before dependency installation
Dockerfile
The builder stage copies web/scripts and documents why the directory must exist before npm install.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

I’m a bunny in the build,
Scripts arrive before the guild.
prepare.js hops in place,
npm runs its proper race.
Docker smiles—no missing trace!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the Docker build failure and the missing prepare.js fix, though it is a bit verbose.
Description check ✅ Passed The description includes the required summary and sufficient background, plus symptom, root cause, fix, and verification details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copilot AI 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.

Pull request overview

Fixes Docker image builds in CI by ensuring the frontend npm install step has access to web/scripts/prepare.js, which is required by the prepare lifecycle script in web/package.json.

Changes:

  • Copy web/scripts into the Docker build context before running npm install in web/.
  • Add inline documentation in the Dockerfile explaining why web/scripts must be present prior to npm install.

Comment thread Dockerfile
Comment on lines 226 to 227
# Install frontend dependencies — depends only on package manifests so
# web source / docs changes don't invalidate this layer.
@JinHai-CN JinHai-CN added the ci Continue Integration label Jul 10, 2026
@JinHai-CN
JinHai-CN merged commit e53235e into infiniflow:main Jul 10, 2026
11 checks passed
@ondery
ondery deleted the fix/docker-web-prepare-script branch July 10, 2026 11:20
@ondery
ondery restored the fix/docker-web-prepare-script branch July 10, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants