score:0

###############################################################
# This stage do:
# 1. Install required software
# 2. Copy package.json and install deps
###############################################################
FROM node:14.17.3-alpine AS build

# This packet are required ONLY for build ??? Otherwise add on final stage
RUN apk add --no-cache build-base gcc autoconf automake libtool zlib-dev libpng-dev nasm

WORKDIR /app/web-web

ENV PATH /app/web-web/node_modules/.bin:$PATH

COPY package.json /app/web-web/package.json

RUN yarn install --network-timeout 1000000000

###############################################################
# This stage do:
# 1. copy node_modules from build stage to this image
# 2. build app and run
###############################################################
FROM node:14.17.3-alpine AS final

WORKDIR /app/web-web
# Magic append here: I copy from prev stage (build) to this one
COPY --from=build /app/web-web .
COPY . /app/web-web

RUN npm i nodemon -g

RUN yarn run build:staging

EXPOSE 3006

CMD ["yarn", "start"]

Related Query

More Query from same tag