5 months ago
Hi, we have an API service that uses prisma. Yesterday deployed an update, everything is fine. Today, nothing changed infrastructure wise, however, on deploying again, started getting the error message below. Database couldn't connect:
deploy log
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 and try installing Prisma again.
I changed to force install the openssl in the dockerfile
Dockerfile was using:
dockerfile
FROM node:20-alpine as builder
...
// added after, worked fine before without these
RUN apk update
RUN apk add --no-cache openssl
...
schema.prisma
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x", "debian-openssl-3.0.x"]
}
Running locally from the same dockerfile worked ok, on the deployed version gave the error.
Tried to change prisma versions in package.json, but that didn't make any change.
What fixed it was changing from node:20-alpine
to node:18-slim
Rolling back to yesterday's deploy (before changing anything in the dockerfile) worked as it should.
I am not that experienced with docker and deploying processes. Maybe could someone explain what could cause the issue?
Could it be some alpine update?
Thank you.
Project ID: 6bd43efc-3425-4163-bbce-f4a714622bd9
2 Replies
Dockerfile nor Prisma versions are not updated at all, but with the same code, the deployment is failed
5 months ago
do not tag the team <#727685388893945877> #5
5 months ago
so after installing openssl in the Dockerfile is your project working again? that wasn't clear to me
5 months ago
from the snippet above it looks like you have?
5 months ago
indeed you are, you are the only one in the comments so my brain thought you where OP
It doesn't work.
Here's the log. Indeed this is related to Prisma, but the main thing is I did not update anything prisma related
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 and try installing Prisma again.
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime "linux-musl".
This happened because Prisma Client was generated for "debian-openssl-3.0.x", but the actual deployment required "linux-musl".
Add "linux-musl" to `binaryTargets` in the "schema.prisma" file and run `prisma generate` after saving it:
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x", "linux-musl-arm64-openssl-3.0.x", "linux-musl"]
}
5 months ago
show me your Dockerfile please
Ok, I was wrong. Adding openssl fixes the deployment. I did that not in the production bulid before
5 months ago
alpine likely changed something
5 months ago
we dont actually recommend using alpine anyway, it has an inferior network stack compared to debian distros
5 months ago
u can solve with this code
RUN ln -s /usr/lib/libssl.so.3 /lib/libssl.so.3
newarifrh
u can solve with this codeRUN ln -s /usr/lib/libssl.so.3 /lib/libssl.so.3
5 months ago
Ok, yes, as you said, adding the openssl in dockerfile fixes it locally, but not on the production
What fixed it for me on production was changing node:20-alpine
to node:18-slim
dockerfile
# Use the Node.js base image (slim version for smaller size)
FROM node:18-slim as builder
# Create app directory
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
RUN apt-get update
RUN apt-get install -y openssl
# Install production dependencies only
RUN npm install
# Copy the rest of the application code
COPY . .
RUN npm run build
# Generate Prisma client
RUN npx prisma generate
# --- Production image ---
FROM node:18-slim
RUN apt-get update
RUN apt-get install -y openssl
# Create app directory
WORKDIR /usr/src/app
# Copy only the necessary files from the builder stage
COPY --from=builder /usr/src/app /usr/src/app
ENV NODE_ENV=production
# Run Prisma migrations before starting the application
CMD ["sh", "-c", "npx prisma migrate deploy && node dist/index.js"]
5 months ago
!s
Status changed to Solved brody • 5 months ago