Skip to content

Commit be6970c

Browse files
committed
Fix Docker build scripts
1 parent f0bbdb1 commit be6970c

4 files changed

Lines changed: 6 additions & 0 deletions

File tree

claude/CLAUDE-KNOWLEDGE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,6 @@ A: Next.js dev app-page runtimes (`app-page*.runtime.dev.js`) include their own
383383

384384
Q: How can we replace the huge `next@16.1.7` patch file with a resilient install-time rewrite?
385385
A: Use a strict root `postinstall` script that rewrites only Next `>=16` app-page dev runtime bundles (`app-page*.runtime.dev.js`) from `doNotLimit=new WeakSet;async_hooks.createHook(` to the guarded `STACK_DISABLE_REACT_ASYNC_DEBUG_INFO` form. Guardrails should fail loud on marker mismatches, mixed guarded/unguarded states, replacement counts not equal to one, or missing runtime fingerprints; the script should also be idempotent (`patched=0, alreadyPatched>0` on second run).
386+
387+
Q: Why can Turbo-pruned Docker builds fail with `Cannot find module /app/scripts/postinstall-patch-next-async-debug-info.mjs` during `pnpm install`?
388+
A: In pruned builder stages, we copy `/app/out/json` and run `pnpm install` before copying `/app/out/full`. The root `package.json` still runs `postinstall: node ./scripts/postinstall-patch-next-async-debug-info.mjs`, but that script is not present yet. Fix by copying `scripts/postinstall-patch-next-async-debug-info.mjs` into the builder stage before `pnpm install` (for all Dockerfiles using the prune pattern).

docker/backend/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ COPY .gitignore .
4444
COPY pnpm-workspace.yaml .
4545
COPY turbo.json .
4646
COPY configs ./configs
47+
COPY --from=pruner /app/scripts/postinstall-patch-next-async-debug-info.mjs ./scripts/
4748
RUN STACK_SKIP_TEMPLATE_GENERATION=true pnpm install --frozen-lockfile
4849

4950
COPY --from=pruner /app/out/full/ .

docker/local-emulator/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ COPY .gitignore .
4242
COPY pnpm-workspace.yaml .
4343
COPY turbo.json .
4444
COPY configs ./configs
45+
COPY --from=pruner /app/scripts/postinstall-patch-next-async-debug-info.mjs ./scripts/
4546
RUN --mount=type=cache,id=pnpm,target=/pnpm/store STACK_SKIP_TEMPLATE_GENERATION=true pnpm install --frozen-lockfile
4647

4748
# copy over the rest of the code for the build

docker/server/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ COPY .gitignore .
4040
COPY pnpm-workspace.yaml .
4141
COPY turbo.json .
4242
COPY configs ./configs
43+
COPY --from=pruner /app/scripts/postinstall-patch-next-async-debug-info.mjs ./scripts/
4344
RUN --mount=type=cache,id=pnpm,target=/pnpm/store STACK_SKIP_TEMPLATE_GENERATION=true pnpm install --frozen-lockfile
4445

4546
# copy over the rest of the code for the build

0 commit comments

Comments
 (0)