Can't I get it to work with `npm install --product...
# orm-help
k
Can't I get it to work with
npm install --production
in docker? I want to lighten the docker image. It would be nice if you could give me an example.
I couldn't find a solution, so I decided to use npm install . 😅.
r
You can use multi staged builds to make it work. For e.g. something like this:
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" ]
I have used
yarn
but the same can be done with
npm
.
💯 1
k
Thanks, I'll give it a try!
👍 1