Repository navigation
fix(seed): put node_modules/.bin on PATH so prisma db seed finds ts-node - #1822
Conversation
Since #1775 the seed image calls the prisma binary by path instead of npx, which no longer adds node_modules/.bin to PATH. prisma db seed then fails with 'spawn ts-node ENOENT' and the compose seed container exits with an error on a fresh install. Found by running the v2.3.0-rc.3 seed image against a fresh Postgres: migrations applied, then the seed failed; with node_modules/.bin on PATH the seed runs. Signed-off-by: Ajay Jadhav <ajay@ayanworks.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Signed-off-by: Ajay Jadhav <ajay@ayanworks.com>
This reverts commit 9bb49b4. Signed-off-by: Ajay Jadhav <ajay@ayanworks.com>
|

Problem
The seed image fails on a fresh install:
```
Running seed command `ts-node prisma/seed.ts` ...
Error: Command failed with ENOENT: ts-node prisma/seed.ts
spawn ts-node ENOENT
```
#1775 replaced `npx prisma` with `/app/node_modules/.bin/prisma` in `Dockerfile.seed`. Calling the binary by path does not add `node_modules/.bin` to `PATH` (npx did), so `prisma db seed` cannot spawn `ts-node` by name. The compose `seed` container exits with an error and the master data is not loaded.
Fix
`ENV PATH=/app/node_modules/.bin:$PATH` in the final stage. The explicit `/app/node_modules/.bin/prisma` calls stay as they are, so the hardening from #1775 is unchanged (no npx).
How it was found / verified
Smoke test of the `v2.3.0-rc.3` images against a fresh Postgres 16:
Not verified: a rebuild of the seed image with this change (the build could not run, the disk was full). The Dockerfile change is one `ENV` line; CI or a local `docker build` will confirm.
Affects `v2.3.0`: needs to be cherry-picked to `release/v2.3`.
Summary by CodeRabbit