From 30c094d19c2085391d49986947339c3235b669b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Wed, 24 Apr 2024 15:00:51 +0200 Subject: [PATCH] nodejs example --- examples/nodejs/tekton/pipeline.yaml | 125 ++++++++++++++++++++++++ examples/nodejs/tekton/pipelinerun.yaml | 57 +++++++++++ tekton/kustomization.yaml | 1 + tekton/task-npm-install.yaml | 20 ++++ 4 files changed, 203 insertions(+) create mode 100644 examples/nodejs/tekton/pipeline.yaml create mode 100644 examples/nodejs/tekton/pipelinerun.yaml create mode 100644 tekton/task-npm-install.yaml diff --git a/examples/nodejs/tekton/pipeline.yaml b/examples/nodejs/tekton/pipeline.yaml new file mode 100644 index 0000000..40ec5a8 --- /dev/null +++ b/examples/nodejs/tekton/pipeline.yaml @@ -0,0 +1,125 @@ +apiVersion: tekton.dev/v1beta1 +kind: Pipeline +metadata: + name: nodejs-hello-world +spec: + + workspaces: + - name: sources + - name: oci-images + - name: registry-token + + params: + - name: git-url + type: string + - name: image-name + type: string + - name: context-dir + type: string + default: "." + - name: containerfile-path + type: string + default: "Containerfile" + + tasks: + + - name: clone-repo-x86-64 + taskRef: + kind: ClusterTask + name: git-clone + params: + - name: url + value: $(params.git-url) + - name: revision + value: "main" + workspaces: + - name: output + workspace: sources + subPath: src-x86_64 + + - name: clone-repo-aarch64 + taskRef: + kind: ClusterTask + name: git-clone + params: + - name: url + value: $(params.git-url) + - name: revision + value: "main" + workspaces: + - name: output + workspace: sources + subPath: src-aarch64 + + - name: npm-install-x86-64 + runAfter: ["clone-repo-x86-64"] + taskRef: + name: npm-install + params: + - name: context-dir + value: $(params.context-dir) + workspaces: + - name: source-workspace + workspace: sources + subPath: src-x86_64 + + - name: npm-install-aarch64 + runAfter: ["clone-repo-aarch64"] + taskRef: + name: npm-install + params: + - name: context-dir + value: $(params.context-dir) + workspaces: + - name: source-workspace + workspace: sources + subPath: src-aarch64 + + - name: build-x86-64 + runAfter: ["npm-install-x86-64"] + taskRef: + name: buildah-build + params: + - name: context-dir + value: $(params.context-dir) + - name: containerfile-path + value: $(params.containerfile-path) + workspaces: + - name: source-workspace + workspace: sources + subPath: src-aarch64 + - name: oci-images + workspace: oci-images + + - name: build-aarch64 + runAfter: ["npm-install-aarch64"] + taskRef: + name: buildah-build + params: + - name: context-dir + value: $(params.context-dir) + - name: containerfile-path + value: $(params.containerfile-path) + workspaces: + - name: source-workspace + workspace: sources + subPath: src-aarch64 + - name: oci-images + workspace: oci-images + + - name: push-image + runAfter: ["build-x86-64", "build-aarch64"] + taskRef: + name: buildah-push + params: + - name: image-name + value: $(params.image-name) + - name: architectures + value: + - x86_64 + - aarch64 + workspaces: + - name: oci-images + workspace: oci-images + - name: dockerconfig + workspace: registry-token diff --git a/examples/nodejs/tekton/pipelinerun.yaml b/examples/nodejs/tekton/pipelinerun.yaml new file mode 100644 index 0000000..e52e9a3 --- /dev/null +++ b/examples/nodejs/tekton/pipelinerun.yaml @@ -0,0 +1,57 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + generateName: nodejs-hello-world- +spec: + pipelineRef: + name: nodejs-hello-world + params: + - name: git-url + value: https://github.com/nmasse-itix/tekton-pipeline-multiarch.git + - name: image-name + value: quay.io/nmasse_itix/nodejs-hello-world-multiarch + - name: context-dir + value: examples/nodejs/src + - name: containerfile-path + value: examples/nodejs/src/Containerfile + workspaces: + - name: oci-images + volumeClaimTemplate: + spec: + storageClassName: efs-csi + accessModes: + - ReadWriteMany + resources: + requests: + storage: 10Gi + - name: sources + volumeClaimTemplate: + spec: + storageClassName: efs-csi + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Gi + - name: registry-token + secret: + secretName: quay-authentication + taskRunTemplate: + serviceAccountName: buildbot + taskRunSpecs: + - pipelineTaskName: npm-install-x86-64 + podTemplate: + nodeSelector: + beta.kubernetes.io/arch: amd64 + - pipelineTaskName: npm-install-aarch64 + podTemplate: + nodeSelector: + beta.kubernetes.io/arch: arm64 + - pipelineTaskName: build-x86-64 + podTemplate: + nodeSelector: + beta.kubernetes.io/arch: amd64 + - pipelineTaskName: build-aarch64 + podTemplate: + nodeSelector: + beta.kubernetes.io/arch: arm64 diff --git a/tekton/kustomization.yaml b/tekton/kustomization.yaml index b1557ba..236c442 100644 --- a/tekton/kustomization.yaml +++ b/tekton/kustomization.yaml @@ -2,3 +2,4 @@ resources: - serviceaccount-buildbot.yaml - task-buildah-build.yaml - task-buildah-push.yaml +- task-npm-install.yaml diff --git a/tekton/task-npm-install.yaml b/tekton/task-npm-install.yaml new file mode 100644 index 0000000..619025d --- /dev/null +++ b/tekton/task-npm-install.yaml @@ -0,0 +1,20 @@ +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: npm-install +spec: + params: + - name: context-dir + type: string + default: . + workspaces: + - name: source-workspace + description: Workspace containing source code + steps: + - name: npm-install + image: registry.access.redhat.com/ubi9/nodejs-20:latest + script: | + #!/bin/bash + set -Eeuo pipefail + cd $(workspaces.source-workspace.path)/$(params.context-dir) + npm install