diff --git a/Accounts/Dockerfile.tpl b/Accounts/Dockerfile.tpl index a0ecb69423..6908bd7a51 100755 --- a/Accounts/Dockerfile.tpl +++ b/Accounts/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -24,7 +24,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -33,7 +34,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -42,7 +44,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -52,7 +55,8 @@ COPY ./CommonServer /usr/src/CommonServer # Install CommonUI -RUN mkdir /usr/src/CommonUI + +FROM Base AS CommonUI WORKDIR /usr/src/CommonUI COPY ./CommonUI/package*.json /usr/src/CommonUI/ RUN npm install --force @@ -61,11 +65,25 @@ COPY ./CommonUI /usr/src/CommonUI #SET ENV Variables +# Install app +FROM Base AS App + +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +WORKDIR /usr/src/CommonUI +COPY --from=CommonUI /usr/src/CommonUI . + + ENV PRODUCTION=true ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true -RUN mkdir /usr/src/app - WORKDIR /usr/src/app # Install app dependencies diff --git a/AdminDashboard/Dockerfile.tpl b/AdminDashboard/Dockerfile.tpl index b42a3c1498..c36f76927a 100755 --- a/AdminDashboard/Dockerfile.tpl +++ b/AdminDashboard/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -24,7 +24,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -32,7 +33,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -41,7 +43,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -51,7 +54,8 @@ COPY ./CommonServer /usr/src/CommonServer # Install CommonUI -RUN mkdir /usr/src/CommonUI + +FROM Base AS CommonUI WORKDIR /usr/src/CommonUI COPY ./CommonUI/package*.json /usr/src/CommonUI/ RUN npm install --force @@ -59,11 +63,25 @@ COPY ./CommonUI /usr/src/CommonUI #SET ENV Variables +# Install app +FROM Base AS App + +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +WORKDIR /usr/src/CommonUI +COPY --from=CommonUI /usr/src/CommonUI . + + ENV PRODUCTION=true ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true -RUN mkdir /usr/src/app - WORKDIR /usr/src/app # Install app dependencies diff --git a/ApiReference/Dockerfile.tpl b/ApiReference/Dockerfile.tpl index 8897683566..c247acac4d 100755 --- a/ApiReference/Dockerfile.tpl +++ b/ApiReference/Dockerfile.tpl @@ -1,5 +1,5 @@ # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -20,7 +20,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -28,7 +29,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -37,7 +39,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -47,8 +50,6 @@ COPY ./CommonServer /usr/src/CommonServer ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true -RUN mkdir /usr/src/app - WORKDIR /usr/src/app # Install app dependencies diff --git a/Dashboard/Dockerfile.tpl b/Dashboard/Dockerfile.tpl index 8fcf45a5e1..4228ff4488 100755 --- a/Dashboard/Dockerfile.tpl +++ b/Dashboard/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -24,7 +24,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -32,7 +33,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -41,7 +43,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -51,7 +54,8 @@ COPY ./CommonServer /usr/src/CommonServer # Install CommonUI -RUN mkdir /usr/src/CommonUI + +FROM Base AS CommonUI WORKDIR /usr/src/CommonUI COPY ./CommonUI/package*.json /usr/src/CommonUI/ RUN npm install --force @@ -59,11 +63,24 @@ COPY ./CommonUI /usr/src/CommonUI #SET ENV Variables +# Install app +FROM Base AS App + +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +WORKDIR /usr/src/CommonUI +COPY --from=CommonUI /usr/src/CommonUI . + ENV PRODUCTION=true ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true -RUN mkdir /usr/src/app - WORKDIR /usr/src/app # Install app dependencies diff --git a/DashboardAPI/Dockerfile.tpl b/DashboardAPI/Dockerfile.tpl index 6ab0b6404c..be9033bcf2 100755 --- a/DashboardAPI/Dockerfile.tpl +++ b/DashboardAPI/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -28,7 +28,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -36,7 +37,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -45,7 +47,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -54,9 +57,19 @@ COPY ./CommonServer /usr/src/CommonServer #SET ENV Variables -ENV PRODUCTION=true +# Install app +FROM Base AS App -RUN mkdir /usr/src/app +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +ENV PRODUCTION=true WORKDIR /usr/src/app diff --git a/File/Dockerfile.tpl b/File/Dockerfile.tpl index b103367639..82891f12de 100644 --- a/File/Dockerfile.tpl +++ b/File/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -28,7 +28,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -36,7 +37,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -45,19 +47,28 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install COPY ./CommonServer /usr/src/CommonServer +# Install app +FROM Base AS App + +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . -#SET ENV Variables ENV PRODUCTION=true -RUN mkdir /usr/src/app - WORKDIR /usr/src/app # Install app dependencies diff --git a/HelmChart/Dockerfile.tpl b/HelmChart/Dockerfile.tpl index ce3bd664cc..e852185eba 100755 --- a/HelmChart/Dockerfile.tpl +++ b/HelmChart/Dockerfile.tpl @@ -1,5 +1,5 @@ # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -20,7 +20,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -28,7 +29,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -37,7 +39,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -45,8 +48,6 @@ COPY ./CommonServer /usr/src/CommonServer -RUN mkdir /usr/src/app - WORKDIR /usr/src/app # Install app dependencies diff --git a/Home/Dockerfile.tpl b/Home/Dockerfile.tpl index bca8f5fc5b..83c3bd6bb9 100755 --- a/Home/Dockerfile.tpl +++ b/Home/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -16,6 +16,18 @@ ENV APP_VERSION=${APP_VERSION} #SET ENV Variables. +# Install app +FROM Base AS App + +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + ENV PRODUCTION=true ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true @@ -29,7 +41,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -37,7 +50,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -45,15 +59,14 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install COPY ./CommonServer /usr/src/CommonServer -RUN mkdir /usr/src/app - WORKDIR /usr/src/app # Install app dependencies diff --git a/Identity/Dockerfile.tpl b/Identity/Dockerfile.tpl index 55cc7a0ab1..334252df0b 100644 --- a/Identity/Dockerfile.tpl +++ b/Identity/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -28,7 +28,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -36,7 +37,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -45,7 +47,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -54,9 +57,19 @@ COPY ./CommonServer /usr/src/CommonServer #SET ENV Variables -ENV PRODUCTION=true +# Install app +FROM Base AS App -RUN mkdir /usr/src/app +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +ENV PRODUCTION=true WORKDIR /usr/src/app diff --git a/Integration/Dockerfile.tpl b/Integration/Dockerfile.tpl index ffd76e140b..66a5c12dc5 100644 --- a/Integration/Dockerfile.tpl +++ b/Integration/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -28,7 +28,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -36,7 +37,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -45,7 +47,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -54,9 +57,19 @@ COPY ./CommonServer /usr/src/CommonServer #SET ENV Variables -ENV PRODUCTION=true +# Install app +FROM Base AS App -RUN mkdir /usr/src/app +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +ENV PRODUCTION=true WORKDIR /usr/src/app diff --git a/Licensing/Dockerfile.tpl b/Licensing/Dockerfile.tpl index df64f90852..b10688429b 100644 --- a/Licensing/Dockerfile.tpl +++ b/Licensing/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -24,7 +24,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -32,7 +33,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -41,7 +43,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -50,11 +53,21 @@ COPY ./CommonServer /usr/src/CommonServer #SET ENV Variables +# Install app +FROM Base AS App + +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + ENV PRODUCTION=true -RUN mkdir /usr/src/app - WORKDIR /usr/src/app # Install app dependencies diff --git a/LinkShortener/Dockerfile.tpl b/LinkShortener/Dockerfile.tpl index 8c7ab115ad..1a187dd2ef 100644 --- a/LinkShortener/Dockerfile.tpl +++ b/LinkShortener/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -28,7 +28,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -36,7 +37,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -44,7 +46,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -53,9 +56,19 @@ COPY ./CommonServer /usr/src/CommonServer #SET ENV Variables -ENV PRODUCTION=true +# Install app +FROM Base AS App -RUN mkdir /usr/src/app +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +ENV PRODUCTION=true WORKDIR /usr/src/app diff --git a/Notification/Dockerfile.tpl b/Notification/Dockerfile.tpl index b3c93fff76..dbd4e454e8 100755 --- a/Notification/Dockerfile.tpl +++ b/Notification/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -24,7 +24,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -32,7 +33,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -41,7 +43,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -50,12 +53,22 @@ COPY ./CommonServer /usr/src/CommonServer #SET ENV Variables +# Install app +FROM Base AS App + +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + ENV PRODUCTION=true ENV CHROME_PATH=/usr/bin/chromium -RUN mkdir /usr/src/app - WORKDIR /usr/src/app # Install app dependencies diff --git a/Probe/Dockerfile.tpl b/Probe/Dockerfile.tpl index b55a3f3632..19c5732602 100644 --- a/Probe/Dockerfile.tpl +++ b/Probe/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -31,7 +31,8 @@ RUN apk add iputils RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -39,7 +40,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -48,7 +50,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -57,9 +60,19 @@ COPY ./CommonServer /usr/src/CommonServer #SET ENV Variables -ENV PRODUCTION=true +# Install app +FROM Base AS App -RUN mkdir /usr/src/app +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +ENV PRODUCTION=true WORKDIR /usr/src/app diff --git a/ProbeAPI/Dockerfile.tpl b/ProbeAPI/Dockerfile.tpl index e454882c4d..807d2fd111 100755 --- a/ProbeAPI/Dockerfile.tpl +++ b/ProbeAPI/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -28,7 +28,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -36,7 +37,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -45,7 +47,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -54,9 +57,19 @@ COPY ./CommonServer /usr/src/CommonServer #SET ENV Variables -ENV PRODUCTION=true +# Install app +FROM Base AS App -RUN mkdir /usr/src/app +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +ENV PRODUCTION=true WORKDIR /usr/src/app diff --git a/Realtime/Dockerfile.tpl b/Realtime/Dockerfile.tpl index a3c99e1bfa..c6e22248d3 100755 --- a/Realtime/Dockerfile.tpl +++ b/Realtime/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -15,6 +15,18 @@ ENV APP_VERSION=${APP_VERSION} #SET ENV Variables +# Install app +FROM Base AS App + +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + ENV PRODUCTION=true # Install bash. @@ -27,7 +39,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -35,7 +48,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -44,7 +58,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -52,8 +67,6 @@ COPY ./CommonServer /usr/src/CommonServer -RUN mkdir /usr/src/app - WORKDIR /usr/src/app # Install app dependencies diff --git a/StatusPage/Dockerfile.tpl b/StatusPage/Dockerfile.tpl index 95520436c0..992a9c7e60 100755 --- a/StatusPage/Dockerfile.tpl +++ b/StatusPage/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -25,7 +25,8 @@ RUN npm install http-server -g RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -33,7 +34,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -42,7 +44,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -50,7 +53,8 @@ COPY ./CommonServer /usr/src/CommonServer # Install CommonUI -RUN mkdir /usr/src/CommonUI + +FROM Base AS CommonUI WORKDIR /usr/src/CommonUI COPY ./CommonUI/package*.json /usr/src/CommonUI/ RUN npm install --force @@ -59,11 +63,24 @@ COPY ./CommonUI /usr/src/CommonUI #SET ENV Variables +# Install app +FROM Base AS App + +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +WORKDIR /usr/src/CommonUI +COPY --from=CommonUI /usr/src/CommonUI . + ENV PRODUCTION=true ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true -RUN mkdir /usr/src/app - WORKDIR /usr/src/app # Install app dependencies diff --git a/TestServer/Dockerfile.tpl b/TestServer/Dockerfile.tpl index 3dde5f2342..0b237a1a85 100755 --- a/TestServer/Dockerfile.tpl +++ b/TestServer/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -28,7 +28,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -36,7 +37,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -45,7 +47,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -54,9 +57,19 @@ COPY ./CommonServer /usr/src/CommonServer #SET ENV Variables -ENV PRODUCTION=true +# Install app +FROM Base AS App -RUN mkdir /usr/src/app +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +ENV PRODUCTION=true WORKDIR /usr/src/app diff --git a/Workers/Dockerfile.tpl b/Workers/Dockerfile.tpl index 084b3ee1d9..4ae845686a 100755 --- a/Workers/Dockerfile.tpl +++ b/Workers/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -31,7 +31,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -39,7 +40,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -48,7 +50,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -57,9 +60,19 @@ COPY ./CommonServer /usr/src/CommonServer #SET ENV Variables -ENV PRODUCTION=true +# Install app +FROM Base AS App -RUN mkdir /usr/src/app +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +ENV PRODUCTION=true WORKDIR /usr/src/app diff --git a/Workflow/Dockerfile.tpl b/Workflow/Dockerfile.tpl index 7b051bc81d..41a52d70c6 100644 --- a/Workflow/Dockerfile.tpl +++ b/Workflow/Dockerfile.tpl @@ -3,7 +3,7 @@ # # Pull base image nodejs image. -FROM node:current-alpine +FROM node:current-alpine as Base USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global @@ -28,7 +28,8 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src # Install common -RUN mkdir /usr/src/Common + +FROM Base AS Common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ RUN npm install @@ -36,7 +37,8 @@ COPY ./Common /usr/src/Common # Install Model -RUN mkdir /usr/src/Model + +FROM Base AS Model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ RUN npm install @@ -44,7 +46,8 @@ COPY ./Model /usr/src/Model # Install CommonServer -RUN mkdir /usr/src/CommonServer + +FROM Base AS CommonServer WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ RUN npm install @@ -53,9 +56,19 @@ COPY ./CommonServer /usr/src/CommonServer #SET ENV Variables -ENV PRODUCTION=true +# Install app +FROM Base AS App -RUN mkdir /usr/src/app +WORKDIR /usr/src/Common +COPY --from=Common /usr/src/Common . + +WORKDIR /usr/src/Model +COPY --from=Model /usr/src/Model . + +WORKDIR /usr/src/CommonServer +COPY --from=CommonServer /usr/src/CommonServer . + +ENV PRODUCTION=true WORKDIR /usr/src/app