Can i get clarification regarding the @Prisma/clie...
# orm-help
т
Can i get clarification regarding the @Prisma/client and prisma Prisma aka prisma/cli is a dev dependency and is not required in production When running it inside a docker container without prisma/cli and without running prisma generate first i get this error
Copy code
Error: @prisma/client did not initialize yet. Please run \"prisma generate\" and try to import it again.\nIn case this error is unexpected for you, please report it in <https://github.com/prisma/prisma/issues>\n at new PrismaClient (/usr/app/node_modules/.prisma/client/index.js:3:11)\n at /usr/app/main.js:28701:20\n at Plugin.exec (/usr/app/node_modules/avvio/plugin.js:132:19)\n at Boot.loadPlugin (/usr/app/node_modules/avvio/plugin.js:267:10)\n at Task.release (/usr/app/node_modules/fastq/queue.js:149:16)\n at worked (/usr/app/node_modules/fastq/queue.js:201:10)\n at /usr/app/node_modules/avvio/plugin.js:270:7\n at done (/usr/app/node_modules/avvio/plugin.js:202:5)\n at check (/usr/app/node_modules/avvio/plugin.js:226:9)\n at node:internal/process/task_queues:141:7","type":"Error","msg":"@prisma/client did not initialize yet. Please run \"prisma generate\" and try to import it again.\nIn case this error is unexpected for you, please report it in <https://github.com/prisma/prisma/issues>"}
prisma/cli is required to run prisma generate
r
@Тоше 👋 Yes. You can overcome this by using multi-stage builds in Docker. So install all the dependencies first and then only the production ones in the final stage.
т
ty @Ryan much appriciated
🙌 1
is there an example for something similar, that u might have came across
r
Yeah sure, something like this should work:
Copy code
FROM node:14.9.0-alpine3.12 as dev

WORKDIR /app

RUN apk add --no-cache --virtual .build-deps alpine-sdk python3

COPY package.json yarn.lock ./

COPY prisma ./prisma

RUN yarn install --frozen-lockfile

FROM node:14.9.0-alpine3.12

WORKDIR /app

COPY --from=dev /app/package.json /app/yarn.lock /app/prisma ./

RUN yarn install --frozen-lockfile --production && \
  rm -rf node_modules/@prisma/engines

COPY . .

EXPOSE 3001

CMD [ "yarn",  "start" ]
🙌 1