~Dockerfile
.dockerfile
Dockerfile
(text/x-dockerfile)
FROM node:alpine as builder
RUN apk add --no-cache libc6-compat
WORKDIR /app

COPY db/ /app
COPY package.json /app
COPY yarn.lock /app
COPY app.manifest.json /app
COPY .env.production /app

# install production dependencies
RUN yarn install --pure-lockfile --production

# Save production depenencies installed so we can later copy them in the production image
RUN cp -R node_modules /tmp/node_modules

# install all dependencies including devDependencies
RUN yarn install --pure-lockfile
COPY . .

ENV NODE_OPTIONS --openssl-legacy-provider
ENV NODE_ENV production
ENV HOST "localhost"
ENV PORT 4100

# Generate prisma schema
RUN yarn generate
RUN cp -R ./node_modules/.prisma/client /tmp/node_modules/.prisma/client

# Build app
RUN yarn build

FROM node:slim
WORKDIR /app
COPY --from=builder /tmp/node_modules ./node_modules
# COPY --from=builder /app/node_modules/@prisma/client ./node_modules/@prisma/client
COPY --from=builder /tmp/node_modules/.prisma/client ./node_modules/.prisma
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./
COPY --from=builder /app/.env.production ./
COPY ./.env.production ./dist/.env
COPY ./.env.production ./.env

ENV PORT 4100
EXPOSE 4100

CMD [ "yarn", "start" ]