Has anyone have a good solution for dockerizing a ...
# orm-help
n
Has anyone have a good solution for dockerizing a Prisma backend? Due to Prisma having both a devDependency (
prisma
) and a dependency (
@prisma/client
), it feels like I have to fight my way against Prisma defaults. I want to make sure my container only has prod dependencies but doing a
yarn install --production
will fail because
@prisma/client
requires
prisma
.
r
@Noel Martin Llevares 👋 You can perform a multi-stage build in that case. Something like:
Copy code
FROM node:14.18.1-alpine3.14 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.18.1-alpine3.14

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 . .

COPY --from=dev /app/node_modules/.prisma ./node_modules/

EXPOSE 3001

CMD [ "yarn",  "start" ]
n
That looks like a good start. Thank you.
👍 1