Next.js Discord

Discord Forum

Next.js and prisma in a container not working

Unanswered
Garganey posted this in #help-forum
Open in Discord
GarganeyOP
I have a next.js app and use prisma as orm and everything works fine in my local env (NOT in a container). Proplem arose as I tried to deploy my app and moved it therefore into a container. The problem now is that prisma cant find the query-engine. First the problem was that the engine was indeed not at my defined output which I solved. Now the same error shows even though the engine is at the location at which the error message says it couldn't find it. Suspecting that it may be because of the bundling with build that the paths or so may be messed up (just guessing). All in all my knowledge is too limited for ts shit. This is my first react app bruh

Error in pic

Dockerfile:
# demp img
FROM node:20-alpine AS deps
WORKDIR /app

COPY package.json package-lock.json* ./
RUN npm ci


# build img
FROM node:20-alpine AS builder
WORKDIR /app

RUN apk add --no-cache openssl

COPY --from=deps /app/node_modules ./node_modules
COPY . .

ENV DATABASE_URL=bogos

RUN npx prisma generate
RUN npm run build


# prod image
FROM node:20-alpine AS runner
WORKDIR /app

RUN apk add --no-cache openssl

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000

COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/src ./src
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/prisma ./prisma

EXPOSE 3000

CMD ["npm", "start"]


Prisma schema:
generator client {
  provider = "prisma-client-js"
  output = "../src/generated/prisma"
  binaryTargets = ["native", "linux-musl-openssl-3.0.x"]

0 Replies