From 7ffbb8269738b4e742b6bd6d6dc73337c7a4e422 Mon Sep 17 00:00:00 2001 From: adrienne-rio Date: Thu, 1 Aug 2024 20:20:43 +0800 Subject: [PATCH] chore: added multi-stage build --- Dockerfile | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8dbb65a8..a3406b2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,26 @@ -FROM node:18 as base +FROM --platform=$BUILDPLATFORM node:18 as build + +ARG BUILDPLATFORM=linux/arm64 WORKDIR /app -RUN git clone git@github.com:deriv-com/p2p.git && \ - cd p2p && \ - npm install && \ - npm install -g serve && \ - npm run build +ENV HUSKY=0 + +RUN git clone https://github.com/deriv-com/p2p.git . + +RUN npm install + +ENV NODE_ENV=production +RUN npm run build + +FROM --platform=$BUILDPLATFORM node:lts-alpine3.20 + +RUN npm install -g serve + +COPY --from=build /app/dist /dist EXPOSE 4000 ENTRYPOINT ["serve"] -CMD ["-s", "p2p/dist", "-l", "4000"] +CMD ["-s", "dist", "-l", "4000"]