From 7d3d34af7f793198a415fb191502af04a73b9166 Mon Sep 17 00:00:00 2001 From: yiekheng Date: Sun, 10 May 2026 22:31:14 +0800 Subject: [PATCH] fix(docker): copy workspace packages' node_modules into web runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Web container booted but every page logged: Error: Cannot find module 'rrule' at /app/packages/shared/dist/rrule.js Next's standalone tracer copied packages/shared/dist/*.js into the standalone output but didn't follow their require("rrule") chain into packages/shared/node_modules — pnpm's symlinked dep layout isn't always followable by the tracer. Same risk for any other shared/db transitive dep (luxon, cron-parser, drizzle-orm, pg, bcryptjs). Copy packages/shared/node_modules and packages/db/node_modules into the runtime stage explicitly so the standalone require chain resolves. Bot Dockerfile already ships full node_modules so it's unaffected. Co-Authored-By: Claude Opus 4.7 (1M context) --- docker/web.Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docker/web.Dockerfile b/docker/web.Dockerfile index 70e9cb0..d870141 100644 --- a/docker/web.Dockerfile +++ b/docker/web.Dockerfile @@ -42,6 +42,14 @@ 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 # 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