question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: docs - Docker node:16-alpine requires setting `engineType = "binary"` for Prisma to work

See original GitHub issue

Provide environment information

System: OS: Linux 6.0 Fedora Linux 37 (Workstation Edition) CPU: (16) x64 AMD Ryzen 7 PRO 6850U with Radeon Graphics Memory: 23.97 GB / 30.12 GB Container: Yes Shell: 5.9 - /bin/zsh Binaries: Node: 16.19.0 - ~/.volta/tools/image/node/16.19.0/bin/node npm: 8.19.3 - ~/.volta/tools/image/node/16.19.0/bin/npm

ct3aMetadata.initVersion: 6.11.3

Describe the bug

I’ve added a Dockerfile (copy-pasted from the docs, using node:16-alpine as a base image) and docker-compose.yml to a freshly bootstrapped app. I modified index.tsx to run trpc.example.getAll.useQuery(), and received this error message at runtime:

Listening on port 3000 url: http://localhost:3000
prisma:error
Invalid `prisma.example.findMany()` invocation:


Unable to load Node-API Library from /app/node_modules/.prisma/client/libquery_engine-linux-musl.so.node, Library may be corrupt
  • I got a similar error with node:16-buster-slim (pointing to the Debian engine).
  • Changing the base image to node:16-buster fixes the error.
  • Adding engineType = "binary" to Prisma generator client also fixes the error under node:16-alpine.

To reproduce

  • Bootstrap application with trpc and prisma:
npm create t3-app@6.11.3
  • Follow steps 1-3 from the docs
  • Add trpc.example.getAll.useQuery() to index.tsx
  • Use the following minimal docker-compose.yml:
version: "3.9"
services:
  app:
    platform: "linux/amd64"
    build:
      context: .
      dockerfile: Dockerfile
      args:
        NEXT_PUBLIC_CLIENTVAR: "clientvar"
    working_dir: /app
    ports:
      - "3000:3000"
    image: t3-app
    environment:
      - DATABASE_URL=mysql://foo:password@db:3306/bar
  db:
    image: mysql:8
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    ports:
      - 3306:3306
    environment:
      MYSQL_USER: foo
      MYSQL_PASSWORD: password
      MYSQL_DATABASE: bar
      MYSQL_RANDOM_ROOT_PASSWORD: true
    volumes:
      - db:/var/lib/mysql

volumes:
  db: {}
  • Run docker compose up -d --build
  • Visit localhost:3000, then check the logs

Additional information

It’s worth noting that setting engineType = "binary" is not a recommended approach according to the Prisma docs as it introduces additional overhead in the architecture: Query Engine. If there’s a problem with using the Node-API Library in Alpine that seems out of scope for the t3 docs, but might be worth mentioning.

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nicolomaiolicommented, Dec 14, 2022

@nicolomaioli hi, how can I set openssl over openssl1.1-compat ? I have tried node:16-alpine3.16 without success

Change this line in the Dockerfile:

- RUN apk add --no-cache libc6-compat openssl1.1-compat
+ RUN apk add --no-cache libc6-compat openssl

Edit: I believe Alpine 3.17 uses v3 of openssl, which is why you need to specify 1.1. The -compat I think has to do with the fact that Alpine uses musl rather than glibc. Hopefully this helps!

1reaction
josethz00commented, Dec 14, 2022

Change this line in the Dockerfile:

- RUN apk add --no-cache libc6-compat openssl1.1-compat
+ RUN apk add --no-cache libc6-compat openssl

Edit: I believe Alpine 3.17 uses v3 of openssl, which is why you need to specify 1.1. The -compat I think has to do with the fact that Alpine uses musl rather than glibc. Hopefully this helps!

Thank you @nicolomaioli , it works! Using node:16-alpine3.16 and openssl

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue building docker image containing prisma on mac M1
I have a docker image that contains prisma and runs on node16 alpine. ... prisma migrate dev --name init Error: Unknown binaryTarget ......
Read more >
Should you use Prisma?
We're looking to build developer-friendly abstractions for tasks that are complex, error-prone and time-consuming when performed manually. No matter if you're a ...
Read more >
Env var not available at build time - Deployment - Qovery Forum
prisma Error : Get config: Schema Parsing P1012 error: Environment variable not found: DATABASE_URL. --> schema.prisma:8 | 7 | provider = " ...
Read more >
T3-Oss Create-T3-App Issues - IssueHint
bug : docs - Docker node:16-alpine requires setting `engineType = "binary"` for Prisma to work, open, 8, 2022-12-14, 2022-12-13. bug: docs - language...
Read more >
Build a Simple CRUD Node.js App with CockroachDB and ...
js application with CockroachDB and Prisma. Step 1. Start CockroachDB. Use CockroachDB serverless. Use a Local Cluster. Choose your installation method. You can ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found