Skip to content

fix(docker): prune rule deletes runtime modules named like docs - #836

Merged
tcsenpai merged 1 commit into
stabilisationfrom
fix/dockerfile-prune-overmatch
May 21, 2026
Merged

fix(docker): prune rule deletes runtime modules named like docs#836
tcsenpai merged 1 commit into
stabilisationfrom
fix/dockerfile-prune-overmatch

Conversation

@tcsenpai

@tcsenpai tcsenpai commented May 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Containerised node crashes on boot with:

demos-node | error: Cannot find module './changes.js' from
            '/app/node_modules/@mysten/sui/dist/cjs/client/types/index.js'

Root cause

Dockerfile:84-99 runs an aggressive PRUNE_MODULES pass to strip docs and license files from node_modules. The rule uses case-insensitive prefix globs:

find node_modules -type f \( \
    -iname 'CHANGES*' -o \
    ... \
\) -delete

CHANGES* matches changes.js (case-insensitive) — Sui's actual runtime module @mysten/sui/dist/cjs/client/types/changes.js. After prune, the file is missing and client/types/index.js fails its require('./changes.js').

Same overreach exists for every -iname 'X*' entry in the list (README*, HISTORY*, CONTRIBUTING*, AUTHORS*, LICEN[CS]E*, NOTICE*, PATENTS*, code_of_conduct*).

Triggered now because the snapshot-restore branch loads @kynesyslabs/demosdk paths that transitively pull in @mysten/sui; older code paths happened to avoid client/types/index.js.

Fix

Replace each -iname 'X*' with an explicit set of extensionless + doc-extension forms (X, X.md, X.txt, X.rst, plus the common LICENSE-MIT.txt / LICENSE-APACHE.txt variants). Real docs still pruned (~60-100 MB savings preserved); runtime JS modules with doc-sounding names stay.

Verification

After rebuild:

$ docker run --rm demos-node:local ls /app/node_modules/@mysten/sui/dist/cjs/client/types/changes.js
/app/node_modules/@mysten/sui/dist/cjs/client/types/changes.js

$ docker run --rm demos-node:local ls /app/node_modules/@mysten/sui/README.md
ls: cannot access '/app/node_modules/@mysten/sui/README.md': No such file or directory

Both required behaviors preserved.

Test plan

  • docker compose build node succeeds.
  • docker run --rm demos-node:local ls /app/node_modules/@mysten/sui/dist/cjs/client/types/changes.js succeeds.
  • ./run --docker --clean -d boots the node without the Cannot find module './changes.js' error.
  • Image size delta vs prior build is within a few MB (prune still effective).

Summary by CodeRabbit

  • Chores
    • Optimized Docker build process by refining the cleanup of documentation and license files in dependencies. Enhanced filename matching logic improves build efficiency and image size optimization.

Review Change Stack

… docs

The bare `-iname 'CHANGES*'` glob (and siblings) in the
`PRUNE_MODULES` pass at Dockerfile:84-99 deletes any file whose
case-insensitive name starts with the token. That includes runtime
JS modules: `@mysten/sui/dist/cjs/client/types/changes.js` is shipped
by Sui SDK and required by `client/types/index.js`. After prune the
file is gone, so `Cannot find module './changes.js' from
.../client/types/index.js` crashes the node on boot when any
transitive code path hits @mysten/sui (via rubic-sdk →
cetus-sui-clmm-sdk → demos SDK).

Replace each `-iname 'X*'` with an explicit set of extensionless +
doc-extension forms (`X`, `X.md`, `X.txt`, `X.rst`). README.md /
CHANGELOG.md / LICENSE.txt etc still pruned; `changes.js` and any
other `<doc-token>.js` runtime file stays. Verified by rebuild +
`ls node_modules/@mysten/sui/dist/cjs/client/types/changes.js`
present in the resulting image.

No code changes elsewhere. Bare-metal `./run` flow unchanged
(prune is docker-only).
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@tcsenpai
tcsenpai merged commit 08af65d into stabilisation May 21, 2026
2 of 3 checks passed
@tcsenpai
tcsenpai deleted the fix/dockerfile-prune-overmatch branch May 21, 2026 13:43
@greptile-apps

greptile-apps Bot commented May 21, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a Docker boot crash caused by the PRUNE_MODULES step deleting changes.js (a runtime module from @mysten/sui) because the old -iname 'CHANGES*' glob matched any filename starting with "changes" — including .js files. The fix replaces every broad prefix-glob with an explicit allowlist of extensionless and doc-extension forms (X, X.md, X.txt, X.rst).

  • The root cause analysis is correct and the explicit-name approach is sound; real doc files are still removed while runtime modules with doc-sounding names are preserved.
  • The original list included a distinct NOTICES* (plural) entry that was not ported to the new form — NOTICES, NOTICES.md, and NOTICES.txt are not currently matched.

Confidence Score: 4/5

The change is safe to merge; it eliminates an active boot crash with no risk of introducing new module-deletion side effects.

The fix is well-scoped and directly addresses the confirmed crash. The only gap is the missing plural NOTICES variants from the original list, which is a minor pruning regression and does not affect correctness or startup reliability.

Dockerfile lines 84–110 (the PRUNE_MODULES find expression) — specifically the NOTICES omission and the completeness of the license variant list if new dependencies are added later.

Important Files Changed

Filename Overview
Dockerfile Replaces broad prefix globs (e.g. -iname 'CHANGES*') in the PRUNE_MODULES step with explicit extensionless + doc-extension forms; fixes the boot crash caused by deleting changes.js from @mysten/sui. The plural NOTICES form present in the original is not carried over.

Reviews (1): Last reviewed commit: "fix(docker): prune rule deletes legitima..." | Re-trigger Greptile

Comment thread Dockerfile
-iname 'CONTRIBUTORS' -o -iname 'CONTRIBUTORS.md' -o -iname 'CONTRIBUTORS.txt' -o \
-iname 'LICENSE' -o -iname 'LICENSE.md' -o -iname 'LICENSE.txt' -o -iname 'LICENSE-MIT' -o -iname 'LICENSE-APACHE' -o -iname 'LICENSE-MIT.txt' -o -iname 'LICENSE-APACHE.txt' -o \
-iname 'LICENCE' -o -iname 'LICENCE.md' -o -iname 'LICENCE.txt' -o \
-iname 'NOTICE' -o -iname 'NOTICE.md' -o -iname 'NOTICE.txt' -o \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 The original list had a separate -iname 'NOTICES*' entry (distinct from NOTICE*). The new list covers NOTICE, NOTICE.md, NOTICE.txt but not the plural NOTICES, NOTICES.md, NOTICES.txt — which some packages (e.g. Apache-licensed Java/Node libraries) do ship. This is a minor pruning regression rather than a correctness bug, but worth carrying over for completeness.

Suggested change
-iname 'NOTICE' -o -iname 'NOTICE.md' -o -iname 'NOTICE.txt' -o \
-iname 'NOTICE' -o -iname 'NOTICE.md' -o -iname 'NOTICE.txt' -o \
-iname 'NOTICES' -o -iname 'NOTICES.md' -o -iname 'NOTICES.txt' -o \

Comment thread Dockerfile
Comment on lines 101 to 102
-iname 'governance.md' -o \
-iname 'security.md' -o \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 governance.md and security.md use lowercase patterns but sit alongside entries that are conventionally uppercased. Since all entries use -iname (case-insensitive), this is harmless at runtime — it is purely a consistency observation.

Suggested change
-iname 'governance.md' -o \
-iname 'security.md' -o \
-iname 'GOVERNANCE.md' -o \
-iname 'SECURITY.md' -o \

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ec2fba7d-e26f-4c97-9a3f-bd7ccbb74bc9

📥 Commits

Reviewing files that changed from the base of the PR and between e998475 and 6d0d8e4.

📒 Files selected for processing (1)
  • Dockerfile

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


Walkthrough

The Dockerfile's builder stage PRUNE_MODULES block refines the find command that deletes documentation and license files from node_modules dependencies. Broad wildcard patterns are replaced with explicit filename and extension matches to reduce overly aggressive file deletion while clarifying intent through updated comments.

Changes

Docker build stage pruning logic

Layer / File(s) Summary
Node modules pruning pattern refinement
Dockerfile
The find node_modules deletion criteria transitions from broad * globs (e.g., README*, CHANGELOG*) to explicit filename-and-extension matches (e.g., README.md, CHANGELOG.txt), with refined handling of special doc-like files and clarified comments about safe and unsafe patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through Docker's build,
Where wildcards grew a touch too wild—
Now README.md is pinpointed clean,
No stray .txt files left unseen!
Precise pruning keeps the image lean. 🌱

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dockerfile-prune-overmatch

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 and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant