fix(docker): also copy /app/node_modules/.pnpm so workspace symlinks resolve
Previous fix copied packages/shared/node_modules and packages/db/node_modules into the runtime stage, but pnpm's layout makes those entries SYMLINKS into /app/node_modules/.pnpm/<dep>@<ver>/ node_modules/<dep> where the real package files live. Without .pnpm/ in the runtime image, every symlink dangled and require still threw 'Cannot find module rrule'. Add a third COPY for /app/node_modules/.pnpm. Use --link so the docker layer storage deduplicates against the build layer. Same root cause class for any pnpm-managed monorepo deploy: ship .pnpm/ together with the leaf node_modules dirs that point into it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7d3d34af7f
commit
aa7387fca8
@ -42,14 +42,18 @@ ENV HOSTNAME=0.0.0.0
|
||||
COPY --from=build /app/apps/web/.next/standalone ./
|
||||
COPY --from=build /app/apps/web/.next/static ./apps/web/.next/static
|
||||
COPY --from=build /app/apps/web/public ./apps/web/public
|
||||
# Next's standalone tracer copied packages/shared/dist/*.js but
|
||||
# missed their transitive deps — packages/shared/dist/rrule.js does
|
||||
# require("rrule") and the rrule node_modules entry never landed in
|
||||
# the standalone output (pnpm's symlinked layout often confuses the
|
||||
# tracer). Copy the workspace packages' node_modules trees in
|
||||
# directly so the require chain resolves at runtime.
|
||||
COPY --from=build /app/packages/shared/node_modules ./packages/shared/node_modules
|
||||
COPY --from=build /app/packages/db/node_modules ./packages/db/node_modules
|
||||
# pnpm's workspace layout: each packages/<pkg>/node_modules/<dep> is a
|
||||
# symlink into /app/node_modules/.pnpm/<dep>@<ver>/node_modules/<dep>
|
||||
# where the real files live. Copying just packages/<pkg>/node_modules
|
||||
# ships dangling symlinks. Bring the .pnpm content store across too so
|
||||
# every symlink resolves at runtime; this is what unblocks the
|
||||
# `Cannot find module 'rrule'` error from
|
||||
# packages/shared/dist/rrule.js. Use --link to deduplicate the layer
|
||||
# blobs inside docker so the runtime image stays slim despite the
|
||||
# dot-pnpm tree being large.
|
||||
COPY --link --from=build /app/node_modules/.pnpm ./node_modules/.pnpm
|
||||
COPY --link --from=build /app/packages/shared/node_modules ./packages/shared/node_modules
|
||||
COPY --link --from=build /app/packages/db/node_modules ./packages/db/node_modules
|
||||
# Reuse the `node` user (UID/GID 1000) that node:alpine ships with —
|
||||
# `addgroup -g 1000 app` collided with the pre-existing node group.
|
||||
RUN chown -R node:node /app
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user