prisma: prisma fails to find openssl 3.0.x on new bookworm docker.io/node:lts-slim container image
Bug description
An application that is built on docker.io/node:lts (18.16.0-bookworm) fails to run on docker.io/node:lts-slim (18.16.0-bookworm-slim).
This was working previously on the node:18.16.0-bullseye images, node:18.16.0-bookworm-slim no longer includes libssl.
prisma:client checkPlatformCaching:postinstall false +169ms
prisma:client checkPlatformCaching:ciName undefined +1ms
prisma:tryLoadEnv Environment variables not found at null +169ms
prisma:tryLoadEnv Environment variables not found at undefined +0ms
prisma:tryLoadEnv No Environment variables loaded +0ms
prisma:client dirname /project/dist +168ms
prisma:client relativePath ../src/prisma +0ms
prisma:client cwd /project/dist +0ms
prisma:client protocol graphql +0ms
prisma:client clientVersion 4.15.0 +0ms
prisma:client clientEngineType library +0ms
prisma:client:libraryEngine internalSetup +168ms
prisma:get-platform Found distro info:
{
"targetDistro": "debian",
"familyDistro": "debian",
"originalDistro": "debian"
} +0ms
prisma:get-platform Trying platform-specific paths for "debian" (and "ubuntu") +0ms
prisma:get-platform Found distro info:
{
"targetDistro": "debian",
"familyDistro": "debian",
"originalDistro": "debian"
} +1ms
prisma:get-platform Trying platform-specific paths for "debian" (and "ubuntu") +0ms
prisma:get-platform Falling back to "ldconfig" and other generic paths +1ms
prisma:get-platform Falling back to "ldconfig" and other generic paths +10ms
prisma:get-platform Couldn't find any version of libssl or OpenSSL in the system +19ms
prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
Please manually install OpenSSL via `apt-get update -y && apt-get install -y openssl` and try installing Prisma again. If you're running Prisma on Docker, you may also try to replace your base image with `node:lts-slim`, which already ships with OpenSSL installed.
prisma:client:engines:resolveEnginePath enginePath undefined +0ms
Prisma Client could not locate the Query Engine for runtime "debian-openssl-1.1.x".
This happened because Prisma Client was generated for "debian-openssl-3.0.x", but the actual deployment required "debian-openssl-1.1.x".
Add "debian-openssl-1.1.x" to `binaryTargets` in the "schema.prisma" file and run `prisma generate` after saving it:
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-1.1.x"]
}
The following locations have been searched:
/project/dist
/project
/builder/node_modules/@prisma/client
/.prisma/client
/tmp/prisma-engines {
error: PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime "debian-openssl-1.1.x".
This happened because Prisma Client was generated for "debian-openssl-3.0.x", but the actual deployment required "debian-openssl-1.1.x".
Add "debian-openssl-1.1.x" to `binaryTargets` in the "schema.prisma" file and run `prisma generate` after saving it:
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-1.1.x"]
}
The fix is the same as noted in the error messages (apt-get install openssl) but it would appear with the change to Debian 12/bookworm, the node:lts-slim image will no longer be a solution
How to reproduce
Expected behavior
No response
Prisma information
Any prisma, any app, multistage container build onto docker.io/node:lts-slim
FROM node:lts as build
WORKDIR /builder
COPY package.json package-lock.json /builder/
RUN npm install && npm build
FROM node:lts-slim
WORKDIR /project
COPY --from=build /builder/dist/. /project
RUN node /project/app.js
Environment & setup
- OS: Debian
- Database: Postgres
- Node.js version: 18.16.0
Prisma Version
prisma : 4.15.0
@prisma/client : 4.15.0
Current platform : debian-openssl-3.0.x
Query Engine (Node-API) : libquery-engine 8fbc245156db7124f997f4cecdd8d1219e360944 (at ../../node_modules/@prisma/engines/libquery_engine-debian-openssl-3.0.x.so.node)
Migration Engine : migration-engine-cli 8fbc245156db7124f997f4cecdd8d1219e360944 (at ../../node_modules/@prisma/engines/migration-engine-debian-openssl-3.0.x)
Format Wasm : @prisma/prisma-fmt-wasm 4.15.0-28.8fbc245156db7124f997f4cecdd8d1219e360944
Default Engines Hash : 8fbc245156db7124f997f4cecdd8d1219e360944
Studio : 0.484.0
Preview Features : postgresqlExtensions, views
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 21 (5 by maintainers)
Solution! Specifying a version like
node:20.1.0-alpinehelps ensure that your builds are reproducible and secure. This prevents unexpected issues due to changes in the base image.While using an image hash can also achieve this, it’s generally not recommended because it can make maintenance and updates more difficult.
For optimal security and maintainability, consider regularly rebuilding your images and potentially setting up automated builds to incorporate updates to both your application and the base image.
For everyone working on an Alpine based image, you need to install
opensslwithapkI solved the issue by installing openssl at the dockerfile
take a look at the command below is implemented for all the staging step
check my dockerfile below
Follow me for more
github
instagram
medium
youtube
As I’m iterating on this, one thing I realized is that, if you are doing multi-stage builds, make sure that your build container is on the same OS level as the run container. I made the mistake of using node:18 (which recently got updated to run on bookworm) as the builder, and using node:18-bullseye-slim as the runner. The result is that the build process builds libquery_engine-debian-openssl-3.0.x.so.node, which won’t work for node:18-bullseye-slim because that image still use and expects openssl 1.1.x
holyshit im experiencing this too. but prisma is looking for openssl 1.x in my case? running prisma ^4.11.0
am currently reverting to old node docker build
Hi @mhio, you are facing this issue because
node:lts-slimno longer ships withlibsslinstalled as of June 10th 2023, when Debian Bookworm (the Linux distribution on which Node.js’slimDocker images are based on) was released.As Prisma needs OpenSSL to operate correctly, you can fix your Dockerfile as follows:
This should correctly install OpenSSL 3.x in your Docker image.
To those looking for a quick and temporary solution, reverting to node:18.15.0* works.
Today’s image push seems to cause this issue.
This can now be closed, thanks for reporting it 🙌🏼 . If you still experience an issue, let us know.
I think it could be interesting to surface this in our docs given the popularity of these Docker images.
I can recommend using a more specific tag than
node:lts-slim- See all tags on https://hub.docker.com/_/node/This change comes from the fact that
node:lts-slimused to be an alias fornode:lts-bullseye-slim(based on Debian 11 bullseye)node:lts-slimis now an alias fornode:lts-bookworm-slim(based on Debian 12 bookworm)Since the Node.js version can also impact apps, I usually prefer to specify the version too, example:
node:18-bookworm-slimnode:18-bullseye-slimThere are 2 different approaches to solve this issue here:
node:18-bullseye-slim.I can confirm @morpig’s advice. For the time being, let’s use
node:18.15. I use the following:Is there a way to have prisma throw an error in this situation? Maybe some sort of flag I can set? I’d prefer my build fail in this case and catch it early as opposed to at runtime. My issue was not pinning to a specific node alpine image version, but would like to prevent my build from succeeding in the future if prisma fails to detect the libssl/openssl version to use. If anyone has any suggestions it would be appreciated.
@Azleal Just add this to your dockerfile:
Note, we improved the logs since 4.16.0 instead of
It’s now fixed, we do not say to switch to
node:lts-slimas it does not includeopensslanymore. You can usenode:lts-slimbut you will need to addapt-get update -y && apt-get install -y opensslto your Dockerfilefacing the same issue as well on node:18-slim and node:lts-slim