Repository navigation
perf(docker): compile @discordjs/opus once, reuse in prod stage - #1816
Conversation
Copy node_modules from build stage to deps-production, then prune devDeps in-place. Eliminates redundant opus source-compilation during production image build, reducing build time by ~30-45min per image.
📝 WalkthroughWalkthroughThe Docker production dependency stage now reuses built ChangesProduction image dependency and CI verification
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Failed to generate code suggestions for PR |
There was a problem hiding this comment.
No issues found across 1 file
Requires human review: Dockerfile change unverified; production build process modification requires human review.
Re-trigger cubic
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Dockerfile`:
- Line 127: Update the Dockerfile’s npm prune command to include the workspace
scope flags --workspaces and --include-workspace-root, while preserving
--omit=dev and --legacy-peer-deps, so pruning removes devDependencies from the
root and every copied workspace node_modules tree.
- Around line 121-125: Update the Dockerfile dependency-copy stage to copy only
the root /app/node_modules tree and remove the workspace-local copies for
shared, bot, backend, and frontend; do not rely on /app/packages/*/node_modules
existing under the npm workspace installation strategy.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
A green docker build proves layers stack, not that @discordjs/opus loads. #1735 shipped a Prisma engine that crash-looped 262x behind a passing build. Load the production-bot image and require the native addon for real.
…single-compile # Conflicts: # .github/workflows/ci.yml
|
Re: the two CodeRabbit 🟠 Major findings — both tested, both refuted
Tested directly on a minimal npm-workspace fixture (
Plain Note this is exactly what the sibling finding at
The build passes, so the directories exist. And a missing Residual risk (acknowledged, not dismissed): if a version conflict ever forces a devDep to nest under What actually needed proving on this PR was not the prune — it was that the copied (3 bytes = Opus compressing a silent 3840-byte frame — expected.) The gate was verified to fail on a missing module (exit 1), an empty frame (exit 1), and a missing image (exit 125), so a green result means something. |
🤖 I have created a release *beep* *boop* --- <details><summary>2.35.1</summary> ## [2.35.1](v2.35.0...v2.35.1) (2026-07-16) ### Bug Fixes * **deploy:** reconcile auth-config smoke check with production redaction ([#1831](#1831)) ([866e16b](866e16b)) * **docker:** add direct_url to staging and dev compose for prisma migrations ([#1830](#1830)) ([aa1eefb](aa1eefb)) * **frontend:** correct site license text apache 2.0 to isc ([#1826](#1826)) ([bdf63fe](bdf63fe)) ### Performance Improvements * **docker:** compile @discordjs/opus once, reuse in prod stage ([#1816](#1816)) ([9e80f12](9e80f12)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).



Summary
Eliminates double compilation of @discordjs/opus in Docker builds.
Verification required
UNVERIFIED — docker daemon not available in this environment.
To verify:
Should print 'opus OK' and show image size ≤ current main. Confirm opus compiles once only in build log.
Technical notes
Summary by cubic
Compile
@discordjs/opusonce during Docker builds by reusing the compilednode_modulesin the production stage, cutting build time by ~30–45 minutes. CI now tags and loads the bot image and verifies native modules at runtime to catch regressions.Refactors
node_modulesfrom the build stage (root and workspaces) and prune in place withnpm prune --omit=dev --legacy-peer-depsto keep the compiled.node.Bug Fixes
lucky-bot:ci, loads it for the bot only, and requires@discordjs/opusto encode a frame to validate native addons.Written for commit ba4c221. Summary will update on new commits.
Summary by CodeRabbit