Skip to content

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

@nicolomaioli

Description

@nicolomaioli

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions