FROM node:19.1-alpine AS dev RUN apk update && rm -rf /var/cache/apk/* WORKDIR /usr/app # Install node dependencies - done in a separate step so Docker can cache it. COPY yarn.lock . COPY package.json . COPY tsconfig.json . RUN yarn install --ignore-scripts --non-interactive --frozen-lockfile && yarn cache clean COPY . . RUN ls RUN yarn build FROM node:19.1-alpine AS production RUN apk update && rm -rf /var/cache/apk/* WORKDIR /app COPY --from=dev /usr/app/dist /app COPY --from=dev /usr/app/package.json /app/ COPY --from=dev /usr/app/yarn.lock /app/ COPY --from=dev /usr/app/tsconfig.json . RUN chown -R node: . USER node RUN yarn install --non-interactive --frozen-lockfile --production && yarn cache clean CMD ["yarn", "start:prod"]