Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

fix(docker): ship builder node_modules in api/jobs runtime (pruned variant broke module resolution)#10

Merged
ComBba merged 1 commit into
mainfrom
fix/docker-runtime-node-modules
May 12, 2026
Merged

fix(docker): ship builder node_modules in api/jobs runtime (pruned variant broke module resolution)#10
ComBba merged 1 commit into
mainfrom
fix/docker-runtime-node-modules

Conversation

@ComBba
Copy link
Copy Markdown
Contributor

@ComBba ComBba commented May 12, 2026

whyc-api Cloud Run revision failed to start — Cannot find module 'reflect-metadata' from apps/api/dist/main.js (health-check timeout → HealthCheckContainerError). The prod-deps stage (pnpm install --ignore-scripts + pnpm prune --prod, copied into runtime) yielded an image where pnpm's isolated node_modules symlinks didn't resolve at runtime.

Fix: drop prod-deps; copy node_modules + apps/<app>/node_modules from the builder stage verbatim — the exact layout pnpm installed & built with, including the generated Prisma client. Bigger image, but it runs. Same change to Dockerfile.jobs (would hit the same MODULE_NOT_FOUND when the pipeline-kickoff-v2 job executes). Dockerfile.web untouched (Next.js standalone bundles its own node_modules).

Merging re-triggers deploy.yml; expected: deploy-api revision healthy → deploy-websmoke (R9).

🤖 Generated with Claude Code

…uned variant broke module resolution)

whyc-api Cloud Run revision failed to start: 'Cannot find module reflect-metadata'
from apps/api/dist/main.js. The 'prod-deps' stage (pnpm install --ignore-scripts
+ pnpm prune --prod, then COPY into runtime) produced an image where pnpm's
isolated node_modules symlinks didn't resolve at runtime. Drop the prod-deps
stage; copy node_modules + apps/<app>/node_modules from the 'builder' stage
verbatim — the exact layout pnpm installed and built with, including the
generated Prisma client. Larger image, but it actually runs. Same fix for
Dockerfile.jobs (would hit the same MODULE_NOT_FOUND when the job executes).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Warning

Rate limit exceeded

@ComBba has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 31 minutes and 58 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 98b92cba-0cfb-44b5-9e94-ea3999a8462e

📥 Commits

Reviewing files that changed from the base of the PR and between f51c07f and 528212a.

📒 Files selected for processing (2)
  • deploy/Dockerfile.api
  • deploy/Dockerfile.jobs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/docker-runtime-node-modules

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.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates Dockerfile.api and Dockerfile.jobs to copy the full node_modules directory from the builder stage to the runtime stage, bypassing the previous production pruning step to resolve MODULE_NOT_FOUND errors. Feedback indicates that including all devDependencies increases the image size and security attack surface. It is suggested to use pnpm deploy or perform pruning within the builder stage to achieve a lean production image without breaking dependency resolution.

Comment thread deploy/Dockerfile.api
Comment on lines +62 to +63
COPY --from=builder --chown=whyc:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=whyc:nodejs /app/apps/api/node_modules ./apps/api/node_modules
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Shipping the full node_modules from the builder stage includes all devDependencies (e.g., typescript, vitest, and the prisma CLI), which significantly increases the production image size and the security attack surface. While this addresses the module resolution issue, it is a suboptimal trade-off for production environments.

Improvement Opportunity:
The previous failure with pnpm prune --prod likely occurred because it was run in a separate prod-deps stage with only a subset of workspace files, which can break pnpm's symlink resolution. A more robust approach would be to run pnpm prune --prod directly in the builder stage after the build is complete (where all files are present), or use pnpm deploy --prod, which is the idiomatic way to create a self-contained production directory for a workspace package. This would keep the image lean and secure while ensuring all runtime dependencies are correctly resolved.

Comment thread deploy/Dockerfile.jobs
Comment on lines +66 to +67
COPY --from=builder --chown=whyc:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=whyc:nodejs /app/apps/jobs/node_modules ./apps/jobs/node_modules
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similar to Dockerfile.api, copying the entire node_modules directory from the builder stage includes unnecessary devDependencies. For a job runner, this increases pull times and cold starts on Cloud Run. Consider pruning dependencies within the builder stage or using pnpm deploy to maintain a minimal production footprint without breaking module resolution.

@ComBba ComBba merged commit 1c8ec22 into main May 12, 2026
10 checks passed
@ComBba ComBba deleted the fix/docker-runtime-node-modules branch May 12, 2026 12:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant