From 2a6cb194058ef38edb233ffd260f12cff56320fe Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Mon, 2 Oct 2023 12:38:40 +0100 Subject: [PATCH] add pnpm to docker build to speed up builds --- .dockerignore | 1 + Accounts/Dockerfile.tpl | 39 +++------------ AdminDashboard/Dockerfile.tpl | 39 +++------------ ApiReference/Dockerfile.tpl | 29 +++--------- Common/AnalyticsModels/BaseModel.ts | 16 +++++++ .../Services/AnalyticsDatabaseService.ts | 47 +++++++++---------- .../Types/AnalyticsDatabase/FindBy.ts | 12 +++-- Dashboard/Dockerfile.tpl | 39 +++------------ DashboardAPI/Dockerfile.tpl | 33 +++---------- File/Dockerfile.tpl | 29 +++--------- Haraka/Dockerfile.tpl | 1 + Home/Dockerfile.tpl | 29 +++--------- Identity/Dockerfile.tpl | 33 +++---------- Integration/Dockerfile.tpl | 33 +++---------- Licensing/Dockerfile.tpl | 33 +++---------- LinkShortener/Dockerfile.tpl | 34 +++----------- Notification/Dockerfile.tpl | 33 +++---------- Probe/Dockerfile.tpl | 33 +++---------- ProbeAPI/Dockerfile.tpl | 33 +++---------- Realtime/Dockerfile.tpl | 29 +++--------- StatusPage/Dockerfile.tpl | 41 ++++------------ TestServer/Dockerfile.tpl | 33 +++---------- Tests/Dockerfile.tpl | 1 + Workers/Dockerfile.tpl | 33 +++---------- Workflow/Dockerfile.tpl | 33 +++---------- 25 files changed, 169 insertions(+), 547 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3ff05dd7b8..b55be287d5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,6 +6,7 @@ node_modules # dependencies /node_modules node_modules +**/node_modules .idea # testing diff --git a/Accounts/Dockerfile.tpl b/Accounts/Dockerfile.tpl index 0a5d8cad11..a3bc503c47 100755 --- a/Accounts/Dockerfile.tpl +++ b/Accounts/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -26,32 +27,23 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install COPY ./CommonServer /usr/src/CommonServer @@ -59,30 +51,13 @@ COPY ./CommonServer /usr/src/CommonServer # Install CommonUI -FROM base AS commonui WORKDIR /usr/src/CommonUI COPY ./CommonUI/package*.json /usr/src/CommonUI/ -RUN npm install --force +RUN pnpm install --force 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 @@ -91,7 +66,7 @@ WORKDIR /usr/src/app # Install app dependencies COPY ./Accounts/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 3003: accounts diff --git a/AdminDashboard/Dockerfile.tpl b/AdminDashboard/Dockerfile.tpl index a8907cd29b..948bc90011 100755 --- a/AdminDashboard/Dockerfile.tpl +++ b/AdminDashboard/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -26,31 +27,22 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install COPY ./CommonServer /usr/src/CommonServer @@ -58,29 +50,12 @@ COPY ./CommonServer /usr/src/CommonServer # Install CommonUI -FROM base AS commonui WORKDIR /usr/src/CommonUI COPY ./CommonUI/package*.json /usr/src/CommonUI/ -RUN npm install --force +RUN pnpm install --force 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 @@ -89,7 +64,7 @@ WORKDIR /usr/src/app # Install app dependencies COPY ./AdminDashboard/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 3158: AdminDashboard diff --git a/ApiReference/Dockerfile.tpl b/ApiReference/Dockerfile.tpl index 8c5fa14a74..d3b582133c 100755 --- a/ApiReference/Dockerfile.tpl +++ b/ApiReference/Dockerfile.tpl @@ -1,10 +1,11 @@ # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -22,46 +23,28 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm 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 . ENV PRODUCTION=true @@ -71,7 +54,7 @@ WORKDIR /usr/src/app # Install app dependencies COPY ./ApiReference/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. diff --git a/Common/AnalyticsModels/BaseModel.ts b/Common/AnalyticsModels/BaseModel.ts index d331976a59..009b55f5e0 100644 --- a/Common/AnalyticsModels/BaseModel.ts +++ b/Common/AnalyticsModels/BaseModel.ts @@ -257,4 +257,20 @@ export default class AnalyticsDataModel { public set id(v: ObjectID | undefined) { this.setColumnValue('_id', v); } + + public get createdAt(): Date | undefined { + return this.getColumnValue('createdAt') as Date | undefined; + } + + public set createdAt(v: Date | undefined) { + this.setColumnValue('createdAt', v); + } + + public get updatedAt(): Date | undefined { + return this.getColumnValue('updatedAt') as Date | undefined; + } + + public set updatedAt(v: Date | undefined) { + this.setColumnValue('updatedAt', v); + } } diff --git a/CommonServer/Services/AnalyticsDatabaseService.ts b/CommonServer/Services/AnalyticsDatabaseService.ts index 6092ffb658..37905bc74a 100644 --- a/CommonServer/Services/AnalyticsDatabaseService.ts +++ b/CommonServer/Services/AnalyticsDatabaseService.ts @@ -32,6 +32,9 @@ import DeleteBy from '../Types/AnalyticsDatabase/DeleteBy'; import UpdateBy from '../Types/AnalyticsDatabase/UpdateBy'; import FindBy from '../Types/AnalyticsDatabase/FindBy'; import PositiveNumber from 'Common/Types/PositiveNumber'; +import SortOrder from 'Common/Types/BaseDatabase/SortOrder'; +import Query from '../Types/AnalyticsDatabase/Query'; +import Select from '../Types/AnalyticsDatabase/Select'; export default class AnalyticsDatabaseService< TBaseModel extends AnalyticsBaseModel @@ -67,7 +70,7 @@ export default class AnalyticsDatabaseService< withDeleted?: boolean | undefined ): Promise> { try { - let automaticallyAddedCreatedAtInSelect: boolean = false; + if (!findBy.sort || Object.keys(findBy.sort).length === 0) { findBy.sort = { @@ -78,10 +81,6 @@ export default class AnalyticsDatabaseService< findBy.select = {} as any; } - if (!(findBy.select as any)['createdAt']) { - (findBy.select as any)['createdAt'] = true; - automaticallyAddedCreatedAtInSelect = true; - } } const onFind: OnFind = findBy.props.ignoreHooks @@ -104,7 +103,6 @@ export default class AnalyticsDatabaseService< const result: { query: Query; select: Select | null; - relationSelect: RelationSelect | null; } = await ModelPermission.checkReadPermission( this.modelType, onBeforeFind.query, @@ -123,7 +121,7 @@ export default class AnalyticsDatabaseService< onBeforeFind.limit = new PositiveNumber(onBeforeFind.limit); } - const items: Array = await this.getRepository().find({ + let items: Array = await this.getRepository().find({ skip: onBeforeFind.skip.toNumber(), take: onBeforeFind.limit.toNumber(), where: onBeforeFind.query as any, @@ -133,39 +131,40 @@ export default class AnalyticsDatabaseService< withDeleted: withDeleted || false, }); - let decryptedItems: Array = []; - - for (const item of items) { - decryptedItems.push(this.decrypt(item)); - } - - decryptedItems = this.sanitizeFindByItems( - decryptedItems, + items = this.sanitizeFindByItems( + items, onBeforeFind ); - for (const item of decryptedItems) { - if (automaticallyAddedCreatedAtInSelect) { - delete (item as any).createdAt; - } - } - + if (!findBy.props.ignoreHooks) { - decryptedItems = await ( + items = await ( await this.onFindSuccess( { findBy, carryForward }, - decryptedItems + items ) ).carryForward; } - return decryptedItems; + return items; } catch (error) { await this.onFindError(error as Exception); throw this.getException(error as Exception); } } + private sanitizeFindByItems( + items: Array, + findBy: FindBy + ): Array { + // if there's no select then there's nothing to do. + if (!findBy.select) { + return items; + } + + return items; + } + public toTableCreateStatement(): string { if (!this.database) { diff --git a/CommonServer/Types/AnalyticsDatabase/FindBy.ts b/CommonServer/Types/AnalyticsDatabase/FindBy.ts index 58ae197dc8..67e76a629c 100644 --- a/CommonServer/Types/AnalyticsDatabase/FindBy.ts +++ b/CommonServer/Types/AnalyticsDatabase/FindBy.ts @@ -1,7 +1,9 @@ -import AnalyticsBaseModel from 'Common/AnalyticsModels/BaseModel'; -import DatabaseCommonInteractionProps from 'Common/Types/BaseDatabase/DatabaseCommonInteractionProps'; +import BaseModel from 'Common/AnalyticsModels/BaseModel'; +import PositiveNumber from 'Common/Types/PositiveNumber'; +import FindOneBy from './FindOneBy'; -export default interface FindBy { - data: TBaseModel; - props: DatabaseCommonInteractionProps; +export default interface FindBy + extends FindOneBy { + limit: PositiveNumber | number; + skip: PositiveNumber | number; } diff --git a/Dashboard/Dockerfile.tpl b/Dashboard/Dockerfile.tpl index 632734e452..f078f55ed2 100755 --- a/Dashboard/Dockerfile.tpl +++ b/Dashboard/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -26,31 +27,22 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install COPY ./CommonServer /usr/src/CommonServer @@ -58,29 +50,12 @@ COPY ./CommonServer /usr/src/CommonServer # Install CommonUI -FROM base AS commonui WORKDIR /usr/src/CommonUI COPY ./CommonUI/package*.json /usr/src/CommonUI/ -RUN npm install --force +RUN pnpm install --force 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 @@ -88,7 +63,7 @@ WORKDIR /usr/src/app # Install app dependencies COPY ./Dashboard/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 3009: Dashboard diff --git a/DashboardAPI/Dockerfile.tpl b/DashboardAPI/Dockerfile.tpl index 9a426adf86..146ceb0619 100755 --- a/DashboardAPI/Dockerfile.tpl +++ b/DashboardAPI/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -30,55 +31,33 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install 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 WORKDIR /usr/src/app # Install app dependencies COPY ./DashboardAPI/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 3002: OneUptime-backend diff --git a/File/Dockerfile.tpl b/File/Dockerfile.tpl index ac0401a4ca..ddba237ea1 100644 --- a/File/Dockerfile.tpl +++ b/File/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA @@ -31,45 +32,27 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm 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 . ENV PRODUCTION=true @@ -77,7 +60,7 @@ WORKDIR /usr/src/app # Install app dependencies COPY ./File/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. diff --git a/Haraka/Dockerfile.tpl b/Haraka/Dockerfile.tpl index 1eaad67c4c..5c64a6693a 100644 --- a/Haraka/Dockerfile.tpl +++ b/Haraka/Dockerfile.tpl @@ -4,6 +4,7 @@ RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm co RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION diff --git a/Home/Dockerfile.tpl b/Home/Dockerfile.tpl index 561ab306c4..6932811807 100755 --- a/Home/Dockerfile.tpl +++ b/Home/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -23,44 +24,26 @@ RUN apk add bash && apk add curl SHELL ["/bin/bash", "-c"] -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm 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 . ENV PRODUCTION=true ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true @@ -69,7 +52,7 @@ WORKDIR /usr/src/app # Install app dependencies COPY ./Home/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 1444: OneUptime Home diff --git a/Identity/Dockerfile.tpl b/Identity/Dockerfile.tpl index 522501387f..1267516fda 100644 --- a/Identity/Dockerfile.tpl +++ b/Identity/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -30,55 +31,33 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install 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 WORKDIR /usr/src/app # Install app dependencies COPY ./Identity/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 3087: OneUptime-backend diff --git a/Integration/Dockerfile.tpl b/Integration/Dockerfile.tpl index 985fcc388d..78d1d08859 100644 --- a/Integration/Dockerfile.tpl +++ b/Integration/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -30,55 +31,33 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install 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 WORKDIR /usr/src/app # Install app dependencies COPY ./Integration/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. diff --git a/Licensing/Dockerfile.tpl b/Licensing/Dockerfile.tpl index 0ab927c4af..660321288b 100644 --- a/Licensing/Dockerfile.tpl +++ b/Licensing/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -26,48 +27,26 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install 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 @@ -75,7 +54,7 @@ WORKDIR /usr/src/app # Install app dependencies COPY ./Licensing/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 3004: OneUptime-licensing diff --git a/LinkShortener/Dockerfile.tpl b/LinkShortener/Dockerfile.tpl index 2fce957e08..1a89b12e59 100644 --- a/LinkShortener/Dockerfile.tpl +++ b/LinkShortener/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -30,54 +31,33 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN ls +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install 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 WORKDIR /usr/src/app # Install app dependencies COPY ./LinkShortener/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. diff --git a/Notification/Dockerfile.tpl b/Notification/Dockerfile.tpl index 9b1bafd732..1d329e80ce 100755 --- a/Notification/Dockerfile.tpl +++ b/Notification/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -26,48 +27,26 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install 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 @@ -76,7 +55,7 @@ WORKDIR /usr/src/app # Install app dependencies COPY ./Notification/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install diff --git a/Probe/Dockerfile.tpl b/Probe/Dockerfile.tpl index ae5e929b81..442249ce3b 100644 --- a/Probe/Dockerfile.tpl +++ b/Probe/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -33,55 +34,33 @@ RUN apk add iputils RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install 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 WORKDIR /usr/src/app # Install app dependencies COPY ./Probe/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 3087: OneUptime-backend diff --git a/ProbeAPI/Dockerfile.tpl b/ProbeAPI/Dockerfile.tpl index f11c641ca6..b128cc6fc5 100755 --- a/ProbeAPI/Dockerfile.tpl +++ b/ProbeAPI/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -30,55 +31,33 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install 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 WORKDIR /usr/src/app # Install app dependencies COPY ./ProbeAPI/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 3400: OneUptime-probe-api diff --git a/Realtime/Dockerfile.tpl b/Realtime/Dockerfile.tpl index a5c04cd5d7..9fde64d698 100755 --- a/Realtime/Dockerfile.tpl +++ b/Realtime/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -17,45 +18,27 @@ ENV GIT_SHA=${GIT_SHA} ENV APP_VERSION=${APP_VERSION} -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm 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 . ENV PRODUCTION=true ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true @@ -64,7 +47,7 @@ WORKDIR /usr/src/app # Install app dependencies COPY ./Realtime/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. EXPOSE 3300 diff --git a/StatusPage/Dockerfile.tpl b/StatusPage/Dockerfile.tpl index 7172aab27c..7e0e981528 100755 --- a/StatusPage/Dockerfile.tpl +++ b/StatusPage/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -23,64 +24,38 @@ RUN apk add bash && apk add curl #Use bash shell by default SHELL ["/bin/bash", "-c"] -RUN npm install http-server -g +RUN pnpm install http-server -g RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install COPY ./CommonServer /usr/src/CommonServer # Install CommonUI -FROM base AS commonui WORKDIR /usr/src/CommonUI COPY ./CommonUI/package*.json /usr/src/CommonUI/ -RUN npm install --force +RUN pnpm install --force 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 @@ -88,7 +63,7 @@ WORKDIR /usr/src/app # Install app dependencies COPY ./StatusPage/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 3105: StatusPage diff --git a/TestServer/Dockerfile.tpl b/TestServer/Dockerfile.tpl index 7bec5fe260..a1769b3614 100755 --- a/TestServer/Dockerfile.tpl +++ b/TestServer/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -30,55 +31,33 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install 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 WORKDIR /usr/src/app # Install app dependencies COPY ./TestServer/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 3800: OneUptime-test-server-api diff --git a/Tests/Dockerfile.tpl b/Tests/Dockerfile.tpl index e421956eb2..23247ed76e 100644 --- a/Tests/Dockerfile.tpl +++ b/Tests/Dockerfile.tpl @@ -7,6 +7,7 @@ RUN apk add bash && apk add curl RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION diff --git a/Workers/Dockerfile.tpl b/Workers/Dockerfile.tpl index 111deee06c..84c9c99964 100755 --- a/Workers/Dockerfile.tpl +++ b/Workers/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -33,55 +34,33 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install 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 WORKDIR /usr/src/app # Install app dependencies COPY ./Workers/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports. # - 3452: OneUptime-worker diff --git a/Workflow/Dockerfile.tpl b/Workflow/Dockerfile.tpl index 210ad816cd..7cb2a8fa89 100644 --- a/Workflow/Dockerfile.tpl +++ b/Workflow/Dockerfile.tpl @@ -3,12 +3,13 @@ # # Pull base image nodejs image. -FROM node:current-alpine AS base +FROM node:current-alpine USER root RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global RUN npm config set fetch-retry-maxtimeout 6000000 RUN npm config set fetch-retry-mintimeout 1000000 +RUN npm install -g pnpm ARG GIT_SHA ARG APP_VERSION @@ -30,54 +31,32 @@ SHELL ["/bin/bash", "-c"] RUN mkdir /usr/src -# Install common - -FROM base AS common WORKDIR /usr/src/Common COPY ./Common/package*.json /usr/src/Common/ -RUN npm install +RUN pnpm install COPY ./Common /usr/src/Common -# Install Model - -FROM base AS model WORKDIR /usr/src/Model COPY ./Model/package*.json /usr/src/Model/ -RUN npm install +RUN pnpm install COPY ./Model /usr/src/Model -# Install CommonServer - -FROM base AS commonserver WORKDIR /usr/src/CommonServer COPY ./CommonServer/package*.json /usr/src/CommonServer/ -RUN npm install +RUN pnpm install 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 WORKDIR /usr/src/app # Install app dependencies COPY ./Workflow/package*.json /usr/src/app/ -RUN npm install +RUN pnpm install # Expose ports.