PrismaP
Prisma2y ago
1 reply
JTB

Prisma NextJs Docker and Multi Datasource

Hello,

thanks for your time.
I use Prisma, Docker and NextJs at work. A combination that is almost unbeatable.
Now I have the following problem, I have several database connections.

So I have the following structure:

./prisma
./prisma/tabelhub/schema.prisma
-->
generator client {
  provider = "prisma-client-js"
  output = "./generated/tablehub"
  binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}

datasource db {
  provider = "mysql"
  url = env("DATABASE_URL")
}

./prisma/camunda/schema.prisma
-->
generator client {
  provider = "prisma-client-js"
  output = "./generated/camunda"
  binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
  previewFeatures = ["views"]
}
datasource db {
  provider = "mysql"
  url = env("DATABASE2_URL")
}


depending on the connection, I simply integrate the client.


This also works with "npm run dev" and the build also starts. However, as soon as I go over to Docker, the second client is not "copied" and built?

Generate the Prisma clients for both schemas

RUN npx prisma generate --schema=./prisma/camunda/schema.prisma && \
    cp ./prisma/camunda/generated/camunda/ ./prisma/camunda/generated/camunda/

RUN npx prisma generate --schema=./prisma/tablehub/schema.prisma && \
    cp ./prisma/camunda/generated/camunda/ ./prisma/tablehub/generated/tablehub/

does anyone have an idea?

Translated with DeepL.com (free version)
Was this page helpful?