From fd1c0ee6a297581a58287a9801c7672816966468 Mon Sep 17 00:00:00 2001 From: Wuesteon Date: Mon, 8 Dec 2025 19:38:49 +0100 Subject: [PATCH] fix(docker): preserve pnpm symlink structure in web Dockerfiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The production stage was copying node_modules to /app, but pnpm creates symlinks pointing to ../../../../../node_modules/.pnpm/ (relative to the app's node_modules location). When the directory structure changed, these symlinks broke, causing "Cannot find package" errors. Fix: - Keep same directory structure in production (/app/apps/*/apps/web) - Copy the root .pnpm store that symlinks point to - Copy the app's node_modules which contains the symlinks Affected apps: todo, manacore, chat, calendar, clock 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/calendar/apps/web/Dockerfile | 12 +++++++++--- apps/chat/apps/web/Dockerfile | 12 +++++++++--- apps/clock/apps/web/Dockerfile | 12 +++++++++--- apps/manacore/apps/web/Dockerfile | 12 +++++++++--- apps/todo/apps/web/Dockerfile | 12 +++++++++--- 5 files changed, 45 insertions(+), 15 deletions(-) diff --git a/apps/calendar/apps/web/Dockerfile b/apps/calendar/apps/web/Dockerfile index ed87318e7..53c964525 100644 --- a/apps/calendar/apps/web/Dockerfile +++ b/apps/calendar/apps/web/Dockerfile @@ -55,12 +55,18 @@ RUN pnpm build # Production stage FROM node:20-alpine AS production -WORKDIR /app +# Keep same directory structure as builder so pnpm symlinks resolve correctly +WORKDIR /app/apps/calendar/apps/web -# Copy built application and node_modules from builder +# Copy the pnpm store that symlinks point to (at /app/node_modules/.pnpm) +COPY --from=builder /app/node_modules/.pnpm /app/node_modules/.pnpm + +# Copy the app's node_modules (contains symlinks to the pnpm store) +COPY --from=builder /app/apps/calendar/apps/web/node_modules ./node_modules + +# Copy built application COPY --from=builder /app/apps/calendar/apps/web/build ./build COPY --from=builder /app/apps/calendar/apps/web/package.json ./ -COPY --from=builder /app/apps/calendar/apps/web/node_modules ./node_modules # Expose port EXPOSE 5186 diff --git a/apps/chat/apps/web/Dockerfile b/apps/chat/apps/web/Dockerfile index f4bf298fc..544d462a2 100644 --- a/apps/chat/apps/web/Dockerfile +++ b/apps/chat/apps/web/Dockerfile @@ -55,12 +55,18 @@ RUN pnpm build # Production stage FROM node:20-alpine AS production -WORKDIR /app +# Keep same directory structure as builder so pnpm symlinks resolve correctly +WORKDIR /app/apps/chat/apps/web -# Copy built application and node_modules from builder +# Copy the pnpm store that symlinks point to (at /app/node_modules/.pnpm) +COPY --from=builder /app/node_modules/.pnpm /app/node_modules/.pnpm + +# Copy the app's node_modules (contains symlinks to the pnpm store) +COPY --from=builder /app/apps/chat/apps/web/node_modules ./node_modules + +# Copy built application COPY --from=builder /app/apps/chat/apps/web/build ./build COPY --from=builder /app/apps/chat/apps/web/package.json ./ -COPY --from=builder /app/apps/chat/apps/web/node_modules ./node_modules # Expose port EXPOSE 3000 diff --git a/apps/clock/apps/web/Dockerfile b/apps/clock/apps/web/Dockerfile index 06b4bc901..2f5e6c366 100644 --- a/apps/clock/apps/web/Dockerfile +++ b/apps/clock/apps/web/Dockerfile @@ -55,12 +55,18 @@ RUN pnpm build # Production stage FROM node:20-alpine AS production -WORKDIR /app +# Keep same directory structure as builder so pnpm symlinks resolve correctly +WORKDIR /app/apps/clock/apps/web -# Copy built application and node_modules from builder +# Copy the pnpm store that symlinks point to (at /app/node_modules/.pnpm) +COPY --from=builder /app/node_modules/.pnpm /app/node_modules/.pnpm + +# Copy the app's node_modules (contains symlinks to the pnpm store) +COPY --from=builder /app/apps/clock/apps/web/node_modules ./node_modules + +# Copy built application COPY --from=builder /app/apps/clock/apps/web/build ./build COPY --from=builder /app/apps/clock/apps/web/package.json ./ -COPY --from=builder /app/apps/clock/apps/web/node_modules ./node_modules # Expose port EXPOSE 5187 diff --git a/apps/manacore/apps/web/Dockerfile b/apps/manacore/apps/web/Dockerfile index f34e22bc1..b400e79d5 100644 --- a/apps/manacore/apps/web/Dockerfile +++ b/apps/manacore/apps/web/Dockerfile @@ -56,12 +56,18 @@ RUN pnpm build # Production stage FROM node:20-alpine AS production -WORKDIR /app +# Keep same directory structure as builder so pnpm symlinks resolve correctly +WORKDIR /app/apps/manacore/apps/web -# Copy built application and node_modules from builder +# Copy the pnpm store that symlinks point to (at /app/node_modules/.pnpm) +COPY --from=builder /app/node_modules/.pnpm /app/node_modules/.pnpm + +# Copy the app's node_modules (contains symlinks to the pnpm store) +COPY --from=builder /app/apps/manacore/apps/web/node_modules ./node_modules + +# Copy built application COPY --from=builder /app/apps/manacore/apps/web/build ./build COPY --from=builder /app/apps/manacore/apps/web/package.json ./ -COPY --from=builder /app/apps/manacore/apps/web/node_modules ./node_modules # Expose port EXPOSE 5173 diff --git a/apps/todo/apps/web/Dockerfile b/apps/todo/apps/web/Dockerfile index 93ec5e7ee..e29ff1815 100644 --- a/apps/todo/apps/web/Dockerfile +++ b/apps/todo/apps/web/Dockerfile @@ -55,12 +55,18 @@ RUN pnpm build # Production stage FROM node:20-alpine AS production -WORKDIR /app +# Keep same directory structure as builder so pnpm symlinks resolve correctly +WORKDIR /app/apps/todo/apps/web -# Copy built application and node_modules from builder +# Copy the pnpm store that symlinks point to (at /app/node_modules/.pnpm) +COPY --from=builder /app/node_modules/.pnpm /app/node_modules/.pnpm + +# Copy the app's node_modules (contains symlinks to the pnpm store) +COPY --from=builder /app/apps/todo/apps/web/node_modules ./node_modules + +# Copy built application COPY --from=builder /app/apps/todo/apps/web/build ./build COPY --from=builder /app/apps/todo/apps/web/package.json ./ -COPY --from=builder /app/apps/todo/apps/web/node_modules ./node_modules # Expose port EXPOSE 5188