prisma: Bun: Can't `prisma generate` on Docker
Bug description
Trying to running prisma generate
inside Docker container build, but it does not happen.
See console output:
It started some Prisma engine downloading, but gives up in about 1~2 seconds after started. Nothing happens, and i can’t prisma generate on container.
Running at my Windows macinhe (through WSL/ Ubuntu) it works fine. Example repository: https://github.com/medeiroshudson/MiniCommerce
(Prisma folder is located at /packages/infrastructure/data/)
# ls
apps bun.lockb config node_modules package.json packages tsconfig.json turbo.json
# bunx prisma generate
> Downloading Prisma engines for Node-API for debian-openssl-1.1.x [======= ] 35%#
It always “fails” at some random percentage.
How to reproduce
1 - Run docker container (see github repo)
2 - Exec bunx prisma generate
inside container
3 - See nothing happening
Expected behavior
Generating prisma client
Prisma information
// Add your schema.prisma
// Add your code using Prisma Client
Environment & setup
Windows WSL Docker Bun 1.0.3
Prisma Version
^5.3.1
About this issue
- Original URL
- State: open
- Created 9 months ago
- Reactions: 22
- Comments: 25 (1 by maintainers)
I faced a similar issue when using Prisma with Bun. The Prisma generate runs ok when I use bun but it’s unable to create a Prisma client when running with docker. Tried to search around but didn’t find any solution yet.
My workaround is to generate it locally with bun (in a non-docker environment) and then ship it with a docker image. Note that I work to change the output of the generator to a different location rather than the default inside node_module. It helps simplify the Dockerfile setup.
Here’s my setup prisma.schema
Setup in Dockerfile
This solution works for me but it violates the docker concept to keep the environment consistent and bring an additional step in the build process to generate clients. In my case, it’s good enough to go with the current situation until I find a better alternative or receive an update from Prisma.
Note that the Prisma client runs differently on different OS so the deployment needs to be tested carefully
Please consider fixing this!
@janpio There appears to have been some progress at Bun to resolve this but some issues still remain. I added more information in https://github.com/oven-sh/bun/issues/5320 including an easy-to-reproduce example.
Update: Got it working after install
nodejs
on docker container. Is there some way to not depending nodejs binaries?Maybe a feature request? Thanks.
Prisma and BunJS don’t particularly go well on Docker so here is a Dockerfile that’ll solve your problems once and for all.
–
Dockerfile as GitHub Gist
Appears to be fixed in Bun 1.0.30
@vutran-tvg Worked for me too, thanks! yes, indeed a not very automated build process…
Thanks man, I had the exact same issue, while using Bun in combination with Prisma. Installing node into the docker container worked for me as well.