fix(docker): preserve pnpm symlink structure in web Dockerfiles

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 <noreply@anthropic.com>
This commit is contained in:
Wuesteon 2025-12-08 19:38:49 +01:00
parent 75d9d18e0d
commit fd1c0ee6a2
5 changed files with 45 additions and 15 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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