FROM node:14-alpine AS base WORKDIR /app RUN mkdir /var/autoplex && chown node:node -R /var/autoplex # Install packages for compiling certain Node libraries FROM base AS base-dev RUN apk add build-base python3 # An image containing necessary components for building FROM base-dev AS builder COPY package.json yarn.lock tsconfig.json ./ RUN rm -rf node_modules && yarn install --frozen-lockfile COPY src src # An image to build the app FROM builder AS build RUN yarn run build # Install production dependencies FROM build AS build-prod RUN rm -rf node_modules && yarn install --production --frozen-lockfile # An image containing the built app and production dependencies FROM base AS prod COPY --from=build-prod /app/build ./build COPY --from=build-prod /app/node_modules ./node_modules COPY package.json yarn.lock ./ CMD [ "yarn", "run", "start" ]