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
RUN yarn install --pure-lockfile --production
RUN cp -R node_modules /tmp/node_modules
RUN yarn install --pure-lockfile
COPY . .
ENV NODE_OPTIONS --openssl-legacy-provider
ENV NODE_ENV production
ENV HOST "localhost"
ENV PORT 4100
RUN yarn generate
RUN cp -R ./node_modules/.prisma/client /tmp/node_modules/.prisma/client
RUN yarn build
FROM node:slim
WORKDIR /app
COPY --from=builder /tmp/node_modules ./node_modules
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" ]