# Stage 1 FROM node:16-alpine as yarn-install WORKDIR /usr/src/app # Install app dependencies COPY package.json yarn.lock ./ RUN apk update && \ apk upgrade && \ apk add --no-cache --virtual build-dependencies bash git openssh python3 make g++ libc6-compat && \ yarn --frozen-lockfile --no-cache && \ apk del build-dependencies && \ yarn cache clean # Runtime container with minimal dependencies FROM node:16-alpine RUN apk update && \ apk upgrade && \ apk add ca-certificates libc6-compat && \ ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2 WORKDIR /usr/src/app COPY --from=yarn-install /usr/src/app/node_modules /usr/src/app/node_modules # Bundle app source COPY . . RUN yarn build EXPOSE 3000 CMD [ "node", "dist/src/main.js" ]