From f4f0262fe0fd276aa98f3d07cfee7227f4a3966a Mon Sep 17 00:00:00 2001 From: Chaz Leong <13462818+cleong14@users.noreply.github.com> Date: Fri, 19 Jul 2024 01:48:14 -1000 Subject: [PATCH] wip: test multi-arch build Signed-off-by: Chaz Leong <13462818+cleong14@users.noreply.github.com> --- angular-ui/Dockerfile | 8 +++++ angular-ui/Jenkinsfile | 66 +++++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/angular-ui/Dockerfile b/angular-ui/Dockerfile index 5a6e85d..b3970a0 100644 --- a/angular-ui/Dockerfile +++ b/angular-ui/Dockerfile @@ -1,22 +1,30 @@ FROM artifactory.cloud.cms.gov/batcave-docker/node:18-alpine AS base WORKDIR /app + RUN apk add --no-cache make python3 g++ + COPY package*.json . + RUN npm ci && npm cache clean --force FROM base AS build COPY . . + RUN npm run build FROM artifactory.cloud.cms.gov/batcave-docker/node:18-alpine WORKDIR /app + EXPOSE 4200 EXPOSE 8888 + USER node + COPY --chown=node:node --from=build /app /app + CMD ["npm", "run", "start", "--", "--host", "0.0.0.0"] diff --git a/angular-ui/Jenkinsfile b/angular-ui/Jenkinsfile index 77d77db..df14b7d 100644 --- a/angular-ui/Jenkinsfile +++ b/angular-ui/Jenkinsfile @@ -3,27 +3,27 @@ pipeline { string(name: 'platform', defaultValue: 'linux/amd64', description: 'A comma separated list of platforms to build the container image for (e.g., linux/amd64,linux/arm64).') } - agent { - kubernetes { - yaml """ - apiVersion: v1 - kind: Pod - spec: - restartPolicy: Never - containers: - - name: build-amd64 - image: artifactory.cloud.cms.gov/batcave-docker/node:18-alpine - command: ['tail', '-f', '/dev/null'] - - name: build-arm64 - image: artifactory.cloud.cms.gov/batcave-docker/node:18-alpine - command: ['tail', '-f', '/dev/null'] - """ - } - } + agent none stages { stage('Build linux/amd64') { + agent { + kubernetes { + yaml """ + apiVersion: v1 + kind: Pod + spec: + restartPolicy: Never + containers: + - name: build-amd64 + image: artifactory.cloud.cms.gov/batcave-docker/node:18-alpine + command: ['tail', '-f', '/dev/null'] + """ + } + label 'linux && x86_64' + } when { + beforeAgent true expression { params.platform.contains('linux/amd64') } } steps { @@ -36,7 +36,23 @@ pipeline { } stage('Build linux/arm64') { + agent { + kubernetes { + yaml """ + apiVersion: v1 + kind: Pod + spec: + restartPolicy: Never + containers: + - name: build-arm64 + image: artifactory.cloud.cms.gov/batcave-docker/node:18-alpine + command: ['tail', '-f', '/dev/null'] + """ + } + label 'linux && aarch64' + } when { + beforeAgent true expression { params.platform.contains('linux/arm64') } } steps { @@ -49,9 +65,7 @@ pipeline { } stage('Test linux/amd64') { - when { - expression { params.platform.contains('linux/amd64') } - } + agent { label 'linux && x86_64' } parallel { stage('Unit Test') { steps { @@ -93,9 +107,7 @@ pipeline { } stage('Test linux/arm64') { - when { - expression { params.platform.contains('linux/arm64') } - } + agent { label 'linux && aarch64' } parallel { stage('Unit Test') { steps { @@ -137,9 +149,7 @@ pipeline { } stage('Delivery linux/amd64') { - when { - expression { params.platform.contains('linux/amd64') } - } + agent { label 'linux && x86_64' } steps { build(job: 'Angular UI Delivery', wait: true, propagate: true, parameters: [ string(name: 'tag', value: "${GIT_COMMIT[0..7]}"), @@ -153,9 +163,7 @@ pipeline { } stage('Delivery linux/arm64') { - when { - expression { params.platform.contains('linux/arm64') } - } + agent { label 'linux && aarch64' } steps { build(job: 'Angular UI Delivery', wait: true, propagate: true, parameters: [ string(name: 'tag', value: "${GIT_COMMIT[0..7]}"),