Skip to content

Commit 73f1e70

Browse files
committed
fix: 🐛 deployment
1 parent 829b638 commit 73f1e70

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

apps/backend/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ RUN pnpm --filter @hype-stack/backend run generate
2121
# Build backend (uses Nx target)
2222
RUN npm run backend:build
2323

24+
# We need to set CI=true to limit node_modules to production dependencies.
25+
RUN CI=true pnpm prune --prod
26+
2427
FROM node:${NODE_VERSION} AS runner
2528
WORKDIR /app
2629
ENV NODE_ENV=production
2730

28-
# Copy runtime artifacts
29-
COPY --from=builder /app/node_modules ./node_modules
30-
COPY --from=builder /app/package.json ./package.json
31-
COPY --from=builder /app/apps/backend/package.json ./apps/backend/package.json
32-
COPY --from=builder /app/apps/backend/dist ./apps/backend/dist
33-
COPY --from=builder /app/apps/backend/src/assets ./apps/backend/src/assets
31+
# Copy the whole workspace. In a pnpm monorepo the backend's deps are symlinks
32+
# in apps/backend/node_modules pointing into the root .pnpm store, and workspace
33+
# packages (e.g. @hype-stack/enums) resolve to their built dist in packages/. The
34+
# build externalizes every dependency, so all of these must exist at runtime.
35+
# pnpm prune --prod already trimmed node_modules to production deps in builder.
36+
COPY --from=builder /app ./
3437

3538
EXPOSE 2138
3639

0 commit comments

Comments
 (0)