appujet / lavamusic

lavalink music bot base in shoukaku and discord.js v14
https://appujet.github.io/lavamusic/
GNU General Public License v3.0
567 stars 491 forks source link

[BUG] arm64 docker image appears to be broken #550

Closed alexandreteles closed 3 months ago

alexandreteles commented 4 months ago

When running the arm64 image, on a clean volume, the logs will read:

PrismaClientInitializationError: Unable to require(`/opt/lavamusic/node_modules/.prisma/client/libquery_engine-linux-arm64-openssl-1.1.x.so.node`).
Prisma cannot find the required `libssl` system library in your system. Please install openssl and try again.
Details: libssl.so.1.1: cannot open shared object file: No such file or directory
    at Object.loadLibrary (/opt/lavamusic/node_modules/@prisma/client/runtime/library.js:111:10219)
    at async wt.loadEngine (/opt/lavamusic/node_modules/@prisma/client/runtime/library.js:112:448)
    at async wt.instantiateLibrary (/opt/lavamusic/node_modules/@prisma/client/runtime/library.js:111:12778) {
  clientVersion: '5.13.0',
  errorCode: undefined
}
Node.js v20.12.2
prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".
Please manually install OpenSSL via `apt-get update -y && apt-get install -y openssl` and try installing Prisma again. If you're running Prisma on Docker, add this command to your Dockerfile, or switch to an image that already has OpenSSL installed.

As an obvious next step I've added OpenSSL to the Docker image in my fork and hit a new error:

PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime "linux-arm64-openssl-3.0.x".
This happened because Prisma Client was generated for "linux-arm64-openssl-1.1.x", but the actual deployment required "linux-arm64-openssl-3.0.x".
Add "linux-arm64-openssl-3.0.x" to `binaryTargets` in the "schema.prisma" file and run `prisma generate` after saving it:
generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "debian-openssl-3.0.x", "linux-arm64-openssl-3.0.x"]
}
The following locations have been searched:
  /opt/lavamusic/node_modules/.prisma/client
  /opt/lavamusic/node_modules/@prisma/client
  /tmp/prisma-engines
  /opt/lavamusic/prisma
    at wa (/opt/lavamusic/node_modules/@prisma/client/runtime/library.js:64:805)
    at async Object.loadLibrary (/opt/lavamusic/node_modules/@prisma/client/runtime/library.js:111:10060)
    at async wt.loadEngine (/opt/lavamusic/node_modules/@prisma/client/runtime/library.js:112:448)
    at async wt.instantiateLibrary (/opt/lavamusic/node_modules/@prisma/client/runtime/library.js:111:12778) {
  clientVersion: '5.13.0',
  errorCode: undefined
}

I followed the recommendation and added the target, just to hit another issue:

[5/4/2024] [7:01:08 PM] [antiCrash.js] [Lavamusic] › ✖  error     Unhandled Rejection at: Promise {
  <rejected> PrismaClientKnownRequestError: 
  Invalid `prisma.stay.findMany()` invocation:

  The table `main.Stay` does not exist in the current database.
      at In.handleRequestError (/opt/lavamusic/node_modules/@prisma/client/runtime/library.js:122:6854)
      at In.handleAndLogRequestError (/opt/lavamusic/node_modules/@prisma/client/runtime/library.js:122:6188)
      at In.request (/opt/lavamusic/node_modules/@prisma/client/runtime/library.js:122:5896)
      at async l (/opt/lavamusic/node_modules/@prisma/client/runtime/library.js:127:11167)
      at async ServerData.get_247 (file:///opt/lavamusic/dist/database/server.js:84:20)
      at async NodeConnect.run (file:///opt/lavamusic/dist/events/player/NodeConnect.js:11:20) {
    code: 'P2021',
    clientVersion: '5.13.0',
    meta: { modelName: 'Stay', table: 'main.Stay' }
  }
} reason: PrismaClientKnownRequestError: 
Invalid `prisma.stay.findMany()` invocation:

When trying to evoke a slash command, it will throw the same error but for the main.Setup table. This seems to be a migration issue, but my Prisma knowledge isn't deep enough to understand what went wrong here. You can check the image build log here: https://github.com/alexandreteles/lavamusic/actions/runs/8952292488/job/24589527694 and you'll see that all the Prisma steps seem to work properly. I wanted to make a PR for this, but now I am unsure of what would be my next step. Is there more information I can provide to help with debug and/or finish a fix and PR?

syleront commented 4 months ago

Not an arm64 only, x86 here and faced with this problem too.

PoulpY2K commented 4 months ago

Hello, I've stumbled upon the same error. Seems like the database is out of sync with the model, which throws the table main.Stay does not exist in the current database error.

As a temporary fix, you can execute the following command to sync the DB with the prisma model : npx prisma db push

This would not happen if we had migrations to apply, but they are not present in the prisma folder. My guess is that Lavamusic has multiple db providers and you have to choose what fits you best.

Although, it should probably appear in the README file.

EDIT: You actually have a step by step guide for prisma in the README, if you actually do the initial migration you will also get in sync with your model.

LemonJoey commented 3 months ago

In the Dockerfile openssl is being installed into the build image and not the production image. To fix this add RUN apt-get update -qq && \ apt-get install -y openssl after Stage 2 not before. You can insert it just after # Stage 2: Create production image FROM node:20-slim ENV NODE_ENV production WORKDIR /opt/lavamusic/ INSERT HERE

elBelgg commented 3 months ago

Fixed in the latest version, I think