fix: correct node_modules path for pnpm symlinks in Docker

The Next.js standalone build creates symlinks in node_modules that point
to ../../../node_modules/.pnpm. When the working directory is /app, these
resolve to /node_modules/.pnpm. Fixed by copying node_modules to /node_modules
instead of /app/node_modules.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock 2025-10-09 18:55:54 -05:00
parent 9a9958a659
commit c12351f2c9
1 changed files with 6 additions and 1 deletions

View File

@ -38,11 +38,16 @@ WORKDIR /app
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nextjs
# Copy built application # Copy built application from standalone output
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public COPY --from=builder --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
# Copy node_modules with proper structure for pnpm symlinks
# The standalone output has symlinks that point to ../../../node_modules/.pnpm
# which resolves to /node_modules/.pnpm when CWD is /app
COPY --from=builder --chown=nextjs:nodejs /app/node_modules /node_modules
# Set up environment # Set up environment
USER nextjs USER nextjs
EXPOSE 3000 EXPOSE 3000