prisma / prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
https://www.prisma.io
Apache License 2.0
39.36k stars 1.54k forks source link

npm generate fails in Docker on M1 MBP #18123

Open krunde-amfam opened 1 year ago

krunde-amfam commented 1 year ago

Bug description

I am using docker-compose to build a new docker image on a M1 MBP. When the docker image builds it fails on npx prisma generate with the following error:

 => ERROR [8/8] RUN npx prisma generate                                                                                                              6.1s
------
 > [8/8] RUN npx prisma generate:
#0 1.412 Prisma schema loaded from prisma/schema.prisma
#0 6.063 Error: Not Found https://binaries.prisma.sh/all_commits/c875e43600dfe042452e0b868f7a48b817b9640b/linux-musl-arm64-openssl-3.0.x/libquery_engine.so.node.gz
------

From what I have read in other issues this is due to missing binaries provided by the Prisma team.

I have upgraded to the latest version of Prisma 4.10.1

How to reproduce

Here is a stripped down version of my Dockerfile. I can confirm this still fails:

FROM node:16-alpine
WORKDIR /app
COPY reflect/cron ./cron
RUN mkdir -p cron
WORKDIR /app/cron
RUN npm config set registry https://registry.npmjs.org/
RUN npm ci
RUN npx prisma generate

The cron folder is source code which I cannot share, but here is the package.json:

{
  "scripts": {
    "build": "tsc --build",
    "clean": "rm -rf dist/",
    "lint": "prettier --check --plugin-search-dir=. . && eslint -c .eslintrc.cjs --ignore-path .gitignore ./src",
    "test": "jest",
    "ci": "npm run-script lint"
  },
  "dependencies": {
    "@aws-sdk/client-pinpoint-email": "^3.112.0",
    "@aws-sdk/client-s3": "^3.137.0",
    "@aws-sdk/s3-request-presigner": "^3.141.0",
    "@pdfme/generator": "^1.0.14",
    "@prisma/client": "^4.3.1",
    "@types/node": "^18.7.17",
    "@types/pdfmake": "^0.2.1",
    "axios": "^0.27.2",
    "dayjs": "^1.11.4",
    "image-size": "^1.0.2",
    "mimemessage": "^1.0.5",
    "node-fpdf": "^1.0.41",
    "pdfmake": "^0.2.6",
    "s3-url-parser": "^1.0.3",
    "sharp": "^0.30.7",
    "ssh2-sftp-client": "^9.0.4"
  },
  "type": "commonjs",
  "devDependencies": {
    "@aws-sdk/types": "^3.127.0",
    "@babel/core": "^7.18.6",
    "@babel/preset-env": "^7.18.6",
    "@babel/preset-typescript": "^7.18.6",
    "@types/jest": "^28.1.4",
    "@types/sharp": "^0.30.4",
    "babel-jest": "^28.1.2",
    "jest": "^28.1.2",
    "prisma": "^4.6.1",
    "ts-jest": "^28.0.5",
    "typescript": "^4.7.4"
  }
}

Expected behavior

I expect npx prisma generate to succeed. Nothing change changed in the schema file or anything else.

Prisma information

// Add your schema.prisma
// Add your code using Prisma Client

Environment & setup

Prisma Version

prisma                  : 4.10.1
@prisma/client          : 4.3.1
Current platform        : darwin-arm64
Query Engine (Node-API) : libquery-engine aead147aa326ccb985dcfed5b065b4fdabd44b19 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine        : migration-engine-cli aead147aa326ccb985dcfed5b065b4fdabd44b19 (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Format Wasm             : @prisma/prisma-fmt-wasm 4.10.1-1.80b351cc7c06d352abe81be19b8a89e9c6b7c110
Default Engines Hash    : aead147aa326ccb985dcfed5b065b4fdabd44b19
Studio                  : 0.481.0
annibuliful commented 1 year ago

Could you try to change from alpine to slim instead https://github.com/prisma/prisma/issues/17071#issuecomment-1420467521

krunde-amfam commented 1 year ago

If I use slim then it does build, but my groups standard is to use alpine and slim breaks other items we include.

rijkvanzanten commented 1 year ago

@jkomyno You mentioned in that linked PR #17071 that Prisma would natively support Alpine images on arm architectures:

[...] and Prisma will also start officially supporting Linux Alpine on arm64 architectures starting from prisma@4.10.0, which will be released in a few hours.

When using Prisma 4.12.0, I'm faced with the same issue as OP (a 404 on the linux-musl-arm64-openssl-3.0.x/libquery_engine.so.node.gz binary). Switching from node:18-alpine to node:18-slim as the base image resolves, it but am I correctly understanding from your comment and docs draft (https://github.com/prisma/docs/issues/4365#issuecomment-1408482282) that the above use case should be supported as per >=prisma@4.10.0?

jkomyno commented 1 year ago

Hi @rijkvanzanten, could you please describe the structure of the project you're using Prisma in? Maybe there are two conflicting versions for prisma and @prisma/client in your package.json file(s)?

Also, using node:18-alpine, could you please run prisma version and copy your output here? Thanks.

rijkvanzanten commented 1 year ago

Hi @rijkvanzanten, could you please describe the structure of the project you're using Prisma in? Maybe there are two conflicting versions for prisma and @prisma/client in your package.json file(s)?

Also, using node:18-alpine, could you please run prisma version and copy your output here? Thanks.

Ah good shout! It was indeed a mismatch in the exact version of prisma and @prisma/client that caused the error. Thanks! Where (if at all) are you taking feature requests? It would be nice if prisma or @prisma/client could throw a helpful error on version mismatches instead of crashing like this 🙂