Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma 3.15.2 does not work on latest node:16-alpine3.17 (node:16-alpine3.16 works) #16834

Closed
proutek opened this issue Dec 15, 2022 · 7 comments
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/engines/query engine Issue in the Query Engine topic: alpine topic: node version

Comments

@proutek
Copy link

proutek commented Dec 15, 2022

Bug description

Suddenly our CI on github started to fail when running build inside docker image with node:16-alpine
After few tryouts I have find out that node:16-alpine3.16 works but latest version node:16-alpine3.17 does not.

Prisma shows this error

Prisma schema loaded from prisma/schema.prisma
Error: Get config: Unable to establish a connection to query-engine-node-api library
@proutek proutek added the kind/bug A reported bug. label Dec 15, 2022
@proutek proutek changed the title Prisma does not work on latest node:16-alpine3.17 (node:16-alpine3.16 works) Prisma 3.15.2 does not work on latest node:16-alpine3.17 (node:16-alpine3.16 works) Dec 15, 2022
@craig-feldman
Copy link

We are using node 18 and prisma 4.6.1 and are also experiencing issues with the latest alpine:

Unable to load Node-API Library from /app/node_modules/.pnpm/@prisma+client@4.6.1_prisma@4.6.1/node_modules/.prisma/client/libquery_engine-linux-musl.so.node, Library may be corrupt

@nickcarnival
Copy link

Same issue here, Github CI node v16.16.0 and @prisma/client: 4.7.1

Error: Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!
Details: Unable to require(`/app/node_modules/prisma/libquery_engine-linux-musl.so.node`)
 Error loading shared library libssl.so.1.1: No such file or directory (needed by /app/node_modules/prisma/libquery_engine-linux-musl.so.node)

@Druue Druue added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. tech/engines/query engine Issue in the Query Engine topic: node version team/client Issue for team Client. topic: alpine labels Dec 15, 2022
@tonton-k37
Copy link

Hi, I'm using fly.io for the hosting service. facing the same issue here. This is my set up files.

#12 3.338 npm WARN exec The following package was not found and will be installed: prisma@4.7.1
#12 26.04 Prisma schema loaded from prisma/schema.prisma
#12 27.07 Error: Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!
#12 27.07 Details: Unable to require(`/root/.npm/_npx/2778af9cee32ff87/node_modules/prisma/libquery_engine-linux-musl.so.node`)
#12 27.07  Error loading shared library libssl.so.1.1: No such file or directory (needed by /root/.npm/_npx/2778af9cee32ff87/node_modules/prisma/libquery_engine-linux-musl.so.node)
# Install dependencies only when needed
FROM node:16-alpine AS builder
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY . .

ENV NEXT_TELEMETRY_DISABLED 1

RUN npx prisma generate
RUN yarn build:nexus

# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /app

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder --chown=node:node /app ./

# USER nextjs
USER node

CMD ["yarn", "start"]
  "dependencies": {
    "@apollo/client": "^3.7.0",
    "@chakra-ui/react": "^2.3.6",
    "@emotion/react": "^11.10.4",
    "@emotion/styled": "^11.10.4",
    "@hookform/resolvers": "^2.9.10",
    "@next-auth/prisma-adapter": "^1.0.5",
    "@prisma/client": "^4.5.0",
    ...
}

@tonton-k37
Copy link

tonton-k37 commented Dec 16, 2022

Hi, I'm using fly.io for the hosting service. facing the same issue here. This is my set up files.

#12 3.338 npm WARN exec The following package was not found and will be installed: prisma@4.7.1
#12 26.04 Prisma schema loaded from prisma/schema.prisma
#12 27.07 Error: Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!
#12 27.07 Details: Unable to require(`/root/.npm/_npx/2778af9cee32ff87/node_modules/prisma/libquery_engine-linux-musl.so.node`)
#12 27.07  Error loading shared library libssl.so.1.1: No such file or directory (needed by /root/.npm/_npx/2778af9cee32ff87/node_modules/prisma/libquery_engine-linux-musl.so.node)
# Install dependencies only when needed
FROM node:16-alpine AS builder
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY . .

ENV NEXT_TELEMETRY_DISABLED 1

RUN npx prisma generate
RUN yarn build:nexus

# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /app

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder --chown=node:node /app ./

# USER nextjs
USER node

CMD ["yarn", "start"]
  "dependencies": {
    "@apollo/client": "^3.7.0",
    "@chakra-ui/react": "^2.3.6",
    "@emotion/react": "^11.10.4",
    "@emotion/styled": "^11.10.4",
    "@hookform/resolvers": "^2.9.10",
    "@next-auth/prisma-adapter": "^1.0.5",
    "@prisma/client": "^4.5.0",
    ...
}

the problem fixed by adding RUN apk add --update --no-cache openssl1.1-compat from the answer of #14073 (comment)
I was able to confirm that the error disappears during the Docker build with the code above. However, I noticed that the error occurred when Prisma actually executed the function.
Finally, I was able to confirm that it was working fine by changing the alpine image used by Docker to node:16-alpine3.16.

@DenzoNL
Copy link

DenzoNL commented Dec 16, 2022

Perhaps it is related due to Alpine 3.17 upgrading to OpenSSL 3.0 from 1.1.1?

@Ketcap
Copy link

Ketcap commented Dec 16, 2022

Using similiar setups with docker.
Getting error of :

"Context creation failed: Unable to load Node-API Library from /app/node_modules/.prisma/client/libquery_engine-linux-musl.so.node, Library may be corrupt"

package.json

...
 "prisma": "^3.15.1",
"@prisma/client": "^3.15.1"
...

In docker

FROM node:16-alpine3.16 AS installer

Builds fine but error thrown on run time.

@jkomyno
Copy link
Contributor

jkomyno commented Dec 16, 2022

Hey everyone, closing as a duplicate of #16553.
Please follow the steps described in #16553 (comment) for a working solution.

TL/DR, you have two choices:

  • Use a Node.js Docker image based on Alpine 3.16, like node:alpine3.16, node:lts-alpine3.16, node:18.12.1-alpine3.16 (encouraged)

  • Install OpenSSL 1.1.x via the openssl1.1-compat package, e.g., by adding

    RUN apk add --update --no-cache openssl1.1-compat

    to your Dockerfile before installing Prisma

Notes:

  • we recommend you to always pin Docker images to a specific version, to ensure reproducible builds
  • we've noticed some comments in similar issues suggesting to install libc / libc6-compat on Linux Alpine to fix the problem. Please DON'T do this, as it could cause other unexpected errors.

@jkomyno jkomyno closed this as completed Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/engines/query engine Issue in the Query Engine topic: alpine topic: node version
Projects
None yet
Development

No branches or pull requests

8 participants