Skip to content

fix: copy Prisma schema into Docker deps stage for postinstall hook#73

Merged
TerrifiedBug merged 1 commit intomainfrom
fix/docker-prisma-postinstall
Mar 8, 2026
Merged

fix: copy Prisma schema into Docker deps stage for postinstall hook#73
TerrifiedBug merged 1 commit intomainfrom
fix/docker-prisma-postinstall

Conversation

@TerrifiedBug
Copy link
Copy Markdown
Owner

Summary

  • PR fix: UI polish foundation — shared utils, component tweaks, accessibility pass #71 added "postinstall": "prisma generate" to package.json, which breaks the Docker build
  • Stage 1 (deps) only copied package.json + pnpm-lock.yaml before running pnpm install --frozen-lockfile — the postinstall hook runs prisma generate but fails because prisma/schema.prisma isn't present yet
  • Fix: copy prisma/ and prisma.config.ts into the deps stage so the postinstall hook succeeds

Root cause

The Dockerfile has a multi-stage build where Stage 1 installs deps (for caching) and Stage 3 copies source + runs prisma generate explicitly. The postinstall script added in #71 made prisma generate run during Stage 1 too, where the schema doesn't exist.

Test plan

  • Docker build completes successfully
  • pnpm install still works locally
  • Prisma client is generated correctly in both stages

PR #71 added `"postinstall": "prisma generate"` to package.json. This
breaks the Docker build because Stage 1 (deps) only copies package.json
and pnpm-lock.yaml before running pnpm install — prisma generate fails
when it can't find the schema. Copy prisma/ and prisma.config.ts into
the deps stage so the postinstall hook succeeds.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 8, 2026

Greptile Summary

This PR fixes a Docker build breakage introduced by PR #71, which added "postinstall": "prisma generate" to package.json. The deps stage (Stage 1) now correctly copies prisma/ and prisma.config.ts before running pnpm install --frozen-lockfile, so the postinstall hook can find the schema and generate the Prisma client successfully.

  • The fix is minimal and directly addresses the root cause.
  • Stage 3 (build) independently copies prisma/ and runs npx prisma generate again — this remains correct and ensures the Prisma client is freshly generated in the build context.
  • One expected trade-off: changes to prisma/schema.prisma or prisma.config.ts will now also invalidate the deps-stage layer cache, triggering a full pnpm install re-run. This is unavoidable given the postinstall hook requirement and is a reasonable outcome.

Confidence Score: 5/5

  • This PR is safe to merge — it's a targeted, correct fix with no logic changes outside the Dockerfile.
  • The change is a two-line Dockerfile addition that directly and correctly solves the stated build failure. Both prisma/ and prisma.config.ts exist in the repo, Stage 3 remains unaffected, and there are no security or correctness concerns introduced.
  • No files require special attention.

Important Files Changed

Filename Overview
docker/server/Dockerfile Adds COPY of prisma/ and prisma.config.ts into the deps stage so the prisma generate postinstall hook has access to the schema — correct fix with the expected trade-off of busting the deps cache on schema changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Stage 1: deps (node:22-alpine)"] -->|"COPY package.json pnpm-lock.yaml"| B
    A -->|"COPY prisma/ prisma.config.ts ✅ NEW"| B
    B["pnpm install --frozen-lockfile\n(postinstall: prisma generate ✅ succeeds)"]
    B --> C["Stage 3: build (node:22-alpine)"]
    C -->|"COPY --from=deps node_modules"| D
    C -->|"COPY prisma/ prisma.config.ts"| D
    D["npx prisma generate\npnpm build"]
    D --> E["Stage 4: runner\n(production image)"]
Loading

Last reviewed commit: 4064dad

@TerrifiedBug TerrifiedBug merged commit 97cc74a into main Mar 8, 2026
9 checks passed
@TerrifiedBug TerrifiedBug deleted the fix/docker-prisma-postinstall branch March 8, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant