P
Prisma2mo ago
uralsmh

Issues with Prisma 5.3.1: OpenSSL Version Mismatch during Build and Runtime in Docker

I am encountering issues with my setup involving Prisma 5.3.1 and Docker. During the build process, I receive the following error: in this GitHub issue, https://github.com/prisma/prisma/issues/16232 which suggests that there is no need to install OpenSSL manually. However, this did not resolve the issue for me.Is there a specific configuration I am missing in my Dockerfile or schema.prisma file that can ensure compatibility? Is there a recommended way to ensure that the Prisma Client is correctly generated for the required OpenSSL version within a Docker environment? Project Details: Prisma Version: 5.3.1 Node Version: 20 Docker Image: node:20-bookworm and node:20-bookworm-slim
FROM node:20-bookworm AS build
WORKDIR /app
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get --no-install-recommends install -y openssl && \
rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json tsconfig.json ./
COPY prisma/schema.prisma ./
RUN --mount=type=cache,target=/app/.npm \
npm set cache /app/.npm && \
npm ci
COPY . .
RUN npx prisma generate && npm run build

FROM node:20-bookworm-slim AS runtime
WORKDIR /app
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/prisma/schema.prisma ./prisma/schema.prisma
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/package-lock.json ./package-lock.json
COPY --from=build /app/dist ./dist

FROM runtime AS collector
CMD ["node","./dist/collector/server.js"]

FROM runtime AS workers
CMD ["node","./dist/workers/master.js"]

FROM runtime AS api
CMD ["node","./dist/api/server.js"]

FROM runtime AS webhook
CMD ["node", "./dist/webhook/server.js"]
FROM node:20-bookworm AS build
WORKDIR /app
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get --no-install-recommends install -y openssl && \
rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json tsconfig.json ./
COPY prisma/schema.prisma ./
RUN --mount=type=cache,target=/app/.npm \
npm set cache /app/.npm && \
npm ci
COPY . .
RUN npx prisma generate && npm run build

FROM node:20-bookworm-slim AS runtime
WORKDIR /app
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/prisma/schema.prisma ./prisma/schema.prisma
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/package-lock.json ./package-lock.json
COPY --from=build /app/dist ./dist

FROM runtime AS collector
CMD ["node","./dist/collector/server.js"]

FROM runtime AS workers
CMD ["node","./dist/workers/master.js"]

FROM runtime AS api
CMD ["node","./dist/api/server.js"]

FROM runtime AS webhook
CMD ["node", "./dist/webhook/server.js"]
5 Replies
uralsmh
uralsmh2mo ago
This is the full error when I ran docker container as well.
PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime "linux-arm64-openssl-1.1.x".

This happened because Prisma Client was generated for "linux-arm64-openssl-3.0.x", but the actual deployment required "linux-arm64-openssl-1.1.x".
Add "linux-arm64-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", "linux-arm64-openssl-1.1.x"]
}

The following locations have been searched:
/app/node_modules/.prisma/client
/app/node_modules/@prisma/client
/tmp/prisma-engines
/app
at va (/app/node_modules/@prisma/client/runtime/library.js:63:805)
at async Object.loadLibrary (/app/node_modules/@prisma/client/runtime/library.js:110:10060)
at async Tr.loadEngine (/app/node_modules/@prisma/client/runtime/library.js:111:448)
at async Tr.instantiateLibrary (/app/node_modules/@prisma/client/runtime/library.js:110:12575) {
clientVersion: '5.17.0',
errorCode: undefined
}
PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime "linux-arm64-openssl-1.1.x".

This happened because Prisma Client was generated for "linux-arm64-openssl-3.0.x", but the actual deployment required "linux-arm64-openssl-1.1.x".
Add "linux-arm64-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", "linux-arm64-openssl-1.1.x"]
}

The following locations have been searched:
/app/node_modules/.prisma/client
/app/node_modules/@prisma/client
/tmp/prisma-engines
/app
at va (/app/node_modules/@prisma/client/runtime/library.js:63:805)
at async Object.loadLibrary (/app/node_modules/@prisma/client/runtime/library.js:110:10060)
at async Tr.loadEngine (/app/node_modules/@prisma/client/runtime/library.js:111:448)
at async Tr.instantiateLibrary (/app/node_modules/@prisma/client/runtime/library.js:110:12575) {
clientVersion: '5.17.0',
errorCode: undefined
}
jonfanz
jonfanz2mo ago
Did you update your schema.prisma with the suggested code?
Add "linux-arm64-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", "linux-arm64-openssl-1.1.x"]
}
Add "linux-arm64-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", "linux-arm64-openssl-1.1.x"]
}
uralsmh
uralsmh2mo ago
@Jon Harrell nope. I have two confusion. 1- Do I really have to install openssl? If yes, do i have to install specifically openssl-1.1.x ? RUN --mount=type=cache,target=/var/cache/apt \ apt-get update && \ apt-get --no-install-recommends install -y openssl && \ rm -rf /var/lib/apt/lists/* 2- Should I really add the binaryTargets in Array?
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-arm64-openssl-1.1.x"]
}
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-arm64-openssl-1.1.x"]
}
jonfanz
jonfanz2mo ago
Add the string "linux-arm64-openssl-1.1.x" to binaryTargets in your prisma.schema and see if that resolves the issue.
uralsmh
uralsmh2mo ago
Will try but should i use 3.x.x? Isn't it up to date one
Want results from more Discord servers?
Add your server