fix(docker): chown @prisma so bot can write migrate engine (#1734)

Merged
LU
5mo ago
+8-1

Fixes #1734 — P1 bot crash-loop (262 restarts, prod down 2026-07-09)

Root cause

production-bot copies node_modules from deps-production (runs npm ci, not prisma generate); the COPY leaves /app/node_modules/@prisma root-owned. Boot CMD npx prisma migrate deploy needs the schema-engine, downloaded into node_modules/@prisma/engines at runtime — container runs as uid 1001 (bot) → write denied → crash-loop.

The client query-engine is fine (baked via custom output = packages/shared/src/generated/prisma). Only the migrate schema-engine download was blocked.

Fix

Add /app/node_modules/@prisma to the production-bot chown → runtime engine download succeeds as the bot user. One line.

Cleanup after deploy

Host has an emergency docker-compose.override.yml running the bot as user: "0:0" (restored prod during the outage). Remove it once this image deploys so the bot runs as uid 1001.

Follow-up (not here)

Bake the schema-engine at build to drop the boot-time Prisma-CDN dependency; add a bot-container liveness dead-man (ran 262 restarts before a human noticed).


Summary by cubic

Bakes @prisma engines from the build stage into the image and chowns /app/node_modules/@prisma to the bot user so npx prisma migrate deploy runs without a runtime download, permission errors, or a Prisma CDN dependency. Fixes #1734.

  • Migration
    • After deploy, remove the emergency docker-compose.override.yml that runs the bot as user: "0:0".