Skip to content

fix(cli): build the code layer with an exclude copy instead of deleting node_modules - #4878

Merged
myftija merged 2 commits into
mainfrom
fix/code-layer-exclude-copy
Sep 2, 2026
Merged

fix(cli): build the code layer with an exclude copy instead of deleting node_modules#4878
myftija merged 2 commits into
mainfrom
fix/code-layer-exclude-copy

Conversation

@myftija

@myftija myftija commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Fixes a deploy slowdown introduced in #4551 to build the code layer, the generated Containerfile deleted node_modules from a snapshot of the build stage.

New approach: the code stage starts empty and copies the app files with the dependency tree excluded.

COPY --exclude is stable in the docker/dockerfile:1 frontend the templates already pin.

…ng node_modules

The code stage was a snapshot of the build stage that ran
`chmod -R u+rwX node_modules && rm -rf node_modules`; on overlayfs the chmod
copies every dependency file into the throwaway layer before the rm walks it
again, which made deploys of large projects markedly slower since 4.5.11.
The stage now copies /app from the build stage with node_modules excluded
(`COPY --exclude`, stable in the dockerfile:1 frontend the templates already
pin), producing the same dependency/code layer split with no extra walks.
@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d35badb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
trigger.dev Patch
@internal/dashboard-agent Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/python Patch
@trigger.dev/react-hooks Patch
@trigger.dev/redis-worker Patch
@trigger.dev/rsc Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/sdk Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@trigger.dev/rbac Patch
@trigger.dev/sso Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/metrics-pipeline Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/run-store Patch
@internal/schedule-engine Patch
@internal/tracing Patch
@internal/webhook-engine Patch
@internal/webhook-sources Patch
@internal/testcontainers Patch
@internal/cache Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Sep 2, 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: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 32290f43-f804-4429-bff7-115b841080f0

📥 Commits

Reviewing files that changed from the base of the PR and between 04d3264 and d35badb.

📒 Files selected for processing (3)
  • .changeset/code-layer-exclude-copy.md
  • packages/cli-v3/src/deploy/buildImage.test.ts
  • packages/cli-v3/src/deploy/buildImage.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (41)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (19, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (21, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (20, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (14, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (15, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (22, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (13, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (24, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (23, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (16, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (17, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (18, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 24)
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - npm)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (2, 2)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (1, 2)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (3, 3)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (1, 3)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - pnpm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: packages / 🧪 Unit Tests: Packages (2, 3)
  • GitHub Check: fk-cascade-guard / fk-cascade-guard
  • GitHub Check: runops-guard / runops-guard
  • GitHub Check: code-quality / code-quality
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: audit
  • GitHub Check: audit
🧰 Additional context used
📓 Path-based instructions (9)
We use vitest exclusively.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/cli-v3/src/deploy/buildImage.test.ts
**Prefer static imports over dynamic imports.**

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/cli-v3/src/deploy/buildImage.ts
  • packages/cli-v3/src/deploy/buildImage.test.ts
Add crumbs as you write code — not just when debugging.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/cli-v3/src/deploy/buildImage.ts
  • packages/cli-v3/src/deploy/buildImage.test.ts
Build Docker images using `src/deploy/buildImage.ts` for local Docker/Depot or remote builds

📄 CodeRabbit inference engine (packages/cli-v3/CLAUDE.md)

Files:

  • packages/cli-v3/src/deploy/buildImage.ts
Deploy mode code should be located in `src/deploy/` and handles bundling, archiving, building Docker images, and pushing to registry

📄 CodeRabbit inference engine (packages/cli-v3/CLAUDE.md)

Files:

  • packages/cli-v3/src/deploy/buildImage.ts
  • packages/cli-v3/src/deploy/buildImage.test.ts
Use vitest for all tests in the Trigger.dev repository

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • packages/cli-v3/src/deploy/buildImage.test.ts
Use function declarations instead of default exports

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • packages/cli-v3/src/deploy/buildImage.ts
  • packages/cli-v3/src/deploy/buildImage.test.ts
Use types over interfaces for TypeScript Avoid using enums; prefer string unions or const objects instead

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • packages/cli-v3/src/deploy/buildImage.ts
  • packages/cli-v3/src/deploy/buildImage.test.ts
When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs Do not use high-cardinality attributes in OTEL metr...

📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)

Files:

  • packages/cli-v3/src/deploy/buildImage.ts
  • packages/cli-v3/src/deploy/buildImage.test.ts
🔇 Additional comments (5)
packages/cli-v3/src/deploy/buildImage.ts (2)

840-842: LGTM!


947-949: LGTM!

packages/cli-v3/src/deploy/buildImage.test.ts (2)

159-160: LGTM!


184-192: LGTM!

.changeset/code-layer-exclude-copy.md (1)

1-5: LGTM!


Walkthrough

The Bun and Node generated Containerfiles now create the code stage from scratch. Each stage copies /app from build while excluding node_modules. Tests validate the new stage declaration, copy instruction, and stage ordering. A patch changeset documents the deployment image build fix.

Merge Risk: ⚪ Minimal · up to d35ba

The code-layer build now copies application files while excluding node_modules instead of deleting dependencies from a build-stage snapshot; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description accurately explains the implementation, but it omits the required template sections for issue closure, checklist, testing, changelog, and screenshots. Add the required template sections. Include the issue reference, completed checklist items, test steps and results, a short changelog entry, and screenshots or an explicit statement that screenshots are not applicable.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and accurately summarizes the main change: using an exclude copy to build the code layer without deleting node_modules.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/code-layer-exclude-copy

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.

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@myftija
myftija added this pull request to the merge queue Sep 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 2, 2026
@myftija
myftija added this pull request to the merge queue Sep 2, 2026
Merged via the queue into main with commit 7447919 Sep 2, 2026
61 checks passed
@myftija
myftija deleted the fix/code-layer-exclude-copy branch September 2, 2026 13:56
@github-actions github-actions Bot mentioned this pull request Sep 2, 2026
pull Bot pushed a commit to erickirt/trigger.dev that referenced this pull request Sep 2, 2026
## Summary
1 improvement, 2 bug fixes.

## Improvements
- The `trigger.dev deploy` and `trigger.dev dev` commands now warn (with
the suggested fix) when your code loads a package through
`createRequire()` that won't be available in the deployed image.
Previously it would fail at runtime in production to load the package.
Deploys also now show bundler warnings for your code instead of
discarding them.
([triggerdotdev#4851](triggerdotdev#4851))

## Bug fixes
- Fixes an issue introduced in 4.5.11 that made deploy image builds of
projects with large dependency trees noticeably slower.
([triggerdotdev#4878](triggerdotdev#4878))

## Server changes

These changes affect the self-hosted Docker image and Trigger.dev Cloud:

- A durable guard improves reliability for runs waiting on
triggerAndWait or batchTriggerAndWait if there's a database error that
interrupts a child run finishing.
([triggerdotdev#4849](triggerdotdev#4849))

<details>
<summary>Raw changeset output</summary>

# Releases
## @trigger.dev/build@4.5.16

### Patch Changes

- The `trigger.dev deploy` and `trigger.dev dev` commands now warn (with
the suggested fix) when your code loads a package through
`createRequire()` that won't be available in the deployed image.
Previously it would fail at runtime in production to load the package.
Deploys also now show bundler warnings for your code instead of
discarding them.
([triggerdotdev#4851](triggerdotdev#4851))
- Updated dependencies:
  - `@trigger.dev/core@4.5.16`
## trigger.dev@4.5.16

### Patch Changes

- Fixes an issue introduced in 4.5.11 that made deploy image builds of
projects with large dependency trees noticeably slower.
([triggerdotdev#4878](triggerdotdev#4878))
- The `trigger.dev deploy` and `trigger.dev dev` commands now warn (with
the suggested fix) when your code loads a package through
`createRequire()` that won't be available in the deployed image.
Previously it would fail at runtime in production to load the package.
Deploys also now show bundler warnings for your code instead of
discarding them.
([triggerdotdev#4851](triggerdotdev#4851))
- Updated dependencies:
  - `@trigger.dev/build@4.5.16`
  - `@trigger.dev/core@4.5.16`
  - `@trigger.dev/schema-to-json@4.5.16`
## @trigger.dev/core@4.5.16

### Patch Changes

- The `trigger.dev deploy` and `trigger.dev dev` commands now warn (with
the suggested fix) when your code loads a package through
`createRequire()` that won't be available in the deployed image.
Previously it would fail at runtime in production to load the package.
Deploys also now show bundler warnings for your code instead of
discarding them.
([triggerdotdev#4851](triggerdotdev#4851))
## @trigger.dev/python@4.5.16

### Patch Changes

- Updated dependencies:
  - `@trigger.dev/build@4.5.16`
  - `@trigger.dev/core@4.5.16`
  - `@trigger.dev/sdk@4.5.16`
## @trigger.dev/react-hooks@4.5.16

### Patch Changes

- Updated dependencies:
  - `@trigger.dev/core@4.5.16`
## @trigger.dev/redis-worker@4.5.16

### Patch Changes

- Updated dependencies:
  - `@trigger.dev/core@4.5.16`
## @trigger.dev/rsc@4.5.16

### Patch Changes

- Updated dependencies:
  - `@trigger.dev/core@4.5.16`
## @trigger.dev/schema-to-json@4.5.16

### Patch Changes

- Updated dependencies:
  - `@trigger.dev/core@4.5.16`
## @trigger.dev/sdk@4.5.16

### Patch Changes

- Updated dependencies:
  - `@trigger.dev/core@4.5.16`

</details>

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants