2022-03-06 13:37:06 +04:00
|
|
|
# Stage 1 - build
|
|
|
|
FROM node:16.14.0-alpine3.15 as build
|
2020-11-23 14:09:33 +03:00
|
|
|
|
2022-04-06 23:46:59 +04:00
|
|
|
## Install build toolchain, install node deps and compile native add-ons
|
2022-09-29 06:41:24 +08:00
|
|
|
RUN apk add --no-cache python3 make g++ git
|
2022-04-06 23:46:59 +04:00
|
|
|
|
2020-11-23 14:09:33 +03:00
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
|
|
|
COPY package.json yarn.lock ./
|
|
|
|
|
2022-04-06 23:46:59 +04:00
|
|
|
RUN yarn install --production
|
|
|
|
|
|
|
|
RUN cp -R node_modules prod_node_modules
|
|
|
|
|
2022-03-05 22:57:23 +04:00
|
|
|
RUN yarn install
|
2020-11-23 14:09:33 +03:00
|
|
|
|
|
|
|
COPY . .
|
|
|
|
|
2022-10-17 08:25:38 +08:00
|
|
|
RUN yarn build-all
|
2022-03-05 22:57:23 +04:00
|
|
|
|
2022-03-06 13:37:06 +04:00
|
|
|
# Stage 2 - make final image
|
|
|
|
FROM node:16.14.0-alpine3.15
|
|
|
|
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
|
|
|
COPY package.json yarn.lock ./
|
2022-04-06 23:46:59 +04:00
|
|
|
COPY --from=build /usr/src/app/prod_node_modules ./node_modules
|
2022-03-06 13:37:06 +04:00
|
|
|
COPY --from=build /usr/src/app/dist ./dist
|
|
|
|
COPY --from=build /usr/src/app/public ./public
|
|
|
|
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
|
2022-10-17 08:25:38 +08:00
|
|
|
CMD ["node", "dist/backend/server.js"]
|