From c49931b53b7d931874617eea9a8255ea59d4beba Mon Sep 17 00:00:00 2001 From: Mangaal Date: Wed, 20 Nov 2024 15:13:33 +0530 Subject: [PATCH 01/12] add Containerfile.plugin and update tekton config for docker file for down stream build Signed-off-by: Mangaal --- .konflux/gitops-backend/Containerfile.plugin | 31 ++++++++++++++++++++ .tekton/gitops-backend-pull-request.yaml | 2 +- .tekton/gitops-backend-push.yaml | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .konflux/gitops-backend/Containerfile.plugin diff --git a/.konflux/gitops-backend/Containerfile.plugin b/.konflux/gitops-backend/Containerfile.plugin new file mode 100644 index 0000000..58583b4 --- /dev/null +++ b/.konflux/gitops-backend/Containerfile.plugin @@ -0,0 +1,31 @@ +# Build Stage +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_golang_1.22 AS builder +WORKDIR /go/src +COPY . /go/src +RUN GIT_COMMIT=$(git rev-parse HEAD) && \ + CGO_ENABLED=0 GOOS=linux go build -a -mod=readonly \ + -ldflags "-X github.com/redhat-developer/gitops-backend/pkg/health.GitRevision=${GIT_COMMIT}" ./cmd/backend-http + +# Final Stage +FROM registry.access.redhat.com/ubi8/ubi-minimal +WORKDIR / +COPY --from=builder /go/src/backend-http . +EXPOSE 8080 +ENTRYPOINT ["./backend-http"] + +LABEL \ + name="openshift-gitops-1/gitops-rhel8" \ + version=${CI_CONTAINER_VERSION} \ + License="Apache 2.0" \ + com.redhat.component="openshift-gitops-container" \ + com.redhat.delivery.appregistry="false" \ + release=${CI_CONTAINER_RELEASE} \ + upstream-version=${CI_UPSTREAM_VERSION} \ + upstream-vcs-ref="${CI_GITOPS_BACKEND_UPSTREAM_COMMIT}" \ + upstream-vcs-type="git" \ + summary="Red Hat OpenShift GitOps Backend Service" \ + io.openshift.expose-services="" \ + io.openshift.tags="openshift,gitops" \ + io.k8s.display-name="Red Hat OpenShift GitOps Backend Service" \ + maintainer="William Tam " \ + description="Red Hat OpenShift GitOps Backend Service" \ No newline at end of file diff --git a/.tekton/gitops-backend-pull-request.yaml b/.tekton/gitops-backend-pull-request.yaml index 00b2dba..2c13eb3 100644 --- a/.tekton/gitops-backend-pull-request.yaml +++ b/.tekton/gitops-backend-pull-request.yaml @@ -27,7 +27,7 @@ spec: - name: image-expires-after value: 5d - name: dockerfile - value: Dockerfile + value: .konflux/gitops-backend/Containerfile.plugin pipelineSpec: description: | This pipeline is ideal for building multi-arch container images from a Containerfile while maintaining trust after pipeline customization. diff --git a/.tekton/gitops-backend-push.yaml b/.tekton/gitops-backend-push.yaml index f01a354..58c645e 100644 --- a/.tekton/gitops-backend-push.yaml +++ b/.tekton/gitops-backend-push.yaml @@ -24,7 +24,7 @@ spec: - name: output-image value: quay.io/redhat-user-workloads/rh-openshift-gitops-tenant/openshift-gitops-operator/gitops-backend:{{revision}} - name: dockerfile - value: Dockerfile + value: .konflux/gitops-backend/Containerfile.plugin pipelineSpec: description: | This pipeline is ideal for building multi-arch container images from a Containerfile while maintaining trust after pipeline customization. From 958fcddd506dbd204806445d4f7ab0e2dff14f0f Mon Sep 17 00:00:00 2001 From: Mangaal Date: Wed, 20 Nov 2024 15:31:09 +0530 Subject: [PATCH 02/12] update Containerfile.plugin file path Signed-off-by: Mangaal --- .konflux/{gitops-backend => }/Containerfile.plugin | 0 .tekton/gitops-backend-pull-request.yaml | 2 +- .tekton/gitops-backend-push.yaml | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename .konflux/{gitops-backend => }/Containerfile.plugin (100%) diff --git a/.konflux/gitops-backend/Containerfile.plugin b/.konflux/Containerfile.plugin similarity index 100% rename from .konflux/gitops-backend/Containerfile.plugin rename to .konflux/Containerfile.plugin diff --git a/.tekton/gitops-backend-pull-request.yaml b/.tekton/gitops-backend-pull-request.yaml index 2c13eb3..0d356e8 100644 --- a/.tekton/gitops-backend-pull-request.yaml +++ b/.tekton/gitops-backend-pull-request.yaml @@ -27,7 +27,7 @@ spec: - name: image-expires-after value: 5d - name: dockerfile - value: .konflux/gitops-backend/Containerfile.plugin + value: .konflux/Containerfile.plugin pipelineSpec: description: | This pipeline is ideal for building multi-arch container images from a Containerfile while maintaining trust after pipeline customization. diff --git a/.tekton/gitops-backend-push.yaml b/.tekton/gitops-backend-push.yaml index 58c645e..9199b6a 100644 --- a/.tekton/gitops-backend-push.yaml +++ b/.tekton/gitops-backend-push.yaml @@ -24,7 +24,7 @@ spec: - name: output-image value: quay.io/redhat-user-workloads/rh-openshift-gitops-tenant/openshift-gitops-operator/gitops-backend:{{revision}} - name: dockerfile - value: .konflux/gitops-backend/Containerfile.plugin + value: .konflux/Containerfile.plugin pipelineSpec: description: | This pipeline is ideal for building multi-arch container images from a Containerfile while maintaining trust after pipeline customization. From c0841d66494303acf385d67e85beae73e98d1ec0 Mon Sep 17 00:00:00 2001 From: Mangaal Date: Tue, 26 Nov 2024 16:54:08 +0530 Subject: [PATCH 03/12] update konflux config Signed-off-by: Mangaal --- .tekton/gitops-backend-pull-request.yaml | 10 ++++++++++ .tekton/gitops-backend-push.yaml | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/.tekton/gitops-backend-pull-request.yaml b/.tekton/gitops-backend-pull-request.yaml index 0d356e8..46464cf 100644 --- a/.tekton/gitops-backend-pull-request.yaml +++ b/.tekton/gitops-backend-pull-request.yaml @@ -26,6 +26,16 @@ spec: value: quay.io/redhat-user-workloads/rh-openshift-gitops-tenant/openshift-gitops-operator/gitops-backend:on-pr-{{revision}} - name: image-expires-after value: 5d + - name: hermetic + value: "true" + - name: prefetch-input + value: '{"type": "gomod", "path": "."}' + - name: build-platforms + value: + - linux/x86_64 + - linux/arm64 + - linux/ppc64le + - linux/s390x - name: dockerfile value: .konflux/Containerfile.plugin pipelineSpec: diff --git a/.tekton/gitops-backend-push.yaml b/.tekton/gitops-backend-push.yaml index 9199b6a..411b7e0 100644 --- a/.tekton/gitops-backend-push.yaml +++ b/.tekton/gitops-backend-push.yaml @@ -23,6 +23,16 @@ spec: value: '{{revision}}' - name: output-image value: quay.io/redhat-user-workloads/rh-openshift-gitops-tenant/openshift-gitops-operator/gitops-backend:{{revision}} + - name: hermetic + value: "true" + - name: prefetch-input + value: '{"type": "gomod", "path": "."}' + - name: build-platforms + value: + - linux/x86_64 + - linux/arm64 + - linux/ppc64le + - linux/s390x - name: dockerfile value: .konflux/Containerfile.plugin pipelineSpec: From 79e6ea0a09a1b510c2b1572adaa745d422ad045f Mon Sep 17 00:00:00 2001 From: Mangaal Date: Thu, 28 Nov 2024 12:39:50 +0530 Subject: [PATCH 04/12] update tekon config Signed-off-by: Mangaal --- .konflux/Containerfile.plugin | 4 ---- .tekton/gitops-backend-pull-request.yaml | 5 ++--- .tekton/gitops-backend-push.yaml | 5 ++--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.konflux/Containerfile.plugin b/.konflux/Containerfile.plugin index 58583b4..881bf0b 100644 --- a/.konflux/Containerfile.plugin +++ b/.konflux/Containerfile.plugin @@ -15,13 +15,9 @@ ENTRYPOINT ["./backend-http"] LABEL \ name="openshift-gitops-1/gitops-rhel8" \ - version=${CI_CONTAINER_VERSION} \ License="Apache 2.0" \ com.redhat.component="openshift-gitops-container" \ com.redhat.delivery.appregistry="false" \ - release=${CI_CONTAINER_RELEASE} \ - upstream-version=${CI_UPSTREAM_VERSION} \ - upstream-vcs-ref="${CI_GITOPS_BACKEND_UPSTREAM_COMMIT}" \ upstream-vcs-type="git" \ summary="Red Hat OpenShift GitOps Backend Service" \ io.openshift.expose-services="" \ diff --git a/.tekton/gitops-backend-pull-request.yaml b/.tekton/gitops-backend-pull-request.yaml index 46464cf..cf02ff4 100644 --- a/.tekton/gitops-backend-pull-request.yaml +++ b/.tekton/gitops-backend-pull-request.yaml @@ -33,9 +33,6 @@ spec: - name: build-platforms value: - linux/x86_64 - - linux/arm64 - - linux/ppc64le - - linux/s390x - name: dockerfile value: .konflux/Containerfile.plugin pipelineSpec: @@ -234,6 +231,8 @@ spec: - $(params.build-args[*]) - name: BUILD_ARGS_FILE value: $(params.build-args-file) + - name: TARGET_VERSION + value: '{{target_branch}} - name: SOURCE_ARTIFACT value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT) - name: CACHI2_ARTIFACT diff --git a/.tekton/gitops-backend-push.yaml b/.tekton/gitops-backend-push.yaml index 411b7e0..26b900a 100644 --- a/.tekton/gitops-backend-push.yaml +++ b/.tekton/gitops-backend-push.yaml @@ -30,9 +30,6 @@ spec: - name: build-platforms value: - linux/x86_64 - - linux/arm64 - - linux/ppc64le - - linux/s390x - name: dockerfile value: .konflux/Containerfile.plugin pipelineSpec: @@ -231,6 +228,8 @@ spec: - $(params.build-args[*]) - name: BUILD_ARGS_FILE value: $(params.build-args-file) + - name: TARGET_VERSION + value: '{{target_branch}}' - name: SOURCE_ARTIFACT value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT) - name: CACHI2_ARTIFACT From 29ceb85f1734e22dcc93f52e44e49faea2fd2b8d Mon Sep 17 00:00:00 2001 From: Mangaal Date: Thu, 28 Nov 2024 12:42:57 +0530 Subject: [PATCH 05/12] update build file Signed-off-by: Mangaal --- .konflux/Containerfile.plugin | 1 + 1 file changed, 1 insertion(+) diff --git a/.konflux/Containerfile.plugin b/.konflux/Containerfile.plugin index 881bf0b..5d6352a 100644 --- a/.konflux/Containerfile.plugin +++ b/.konflux/Containerfile.plugin @@ -15,6 +15,7 @@ ENTRYPOINT ["./backend-http"] LABEL \ name="openshift-gitops-1/gitops-rhel8" \ + version=${TARGET_VERSION} \ License="Apache 2.0" \ com.redhat.component="openshift-gitops-container" \ com.redhat.delivery.appregistry="false" \ From 571e42f98adf4e932c963983ad360d28e4135b90 Mon Sep 17 00:00:00 2001 From: Mangaal Date: Thu, 28 Nov 2024 12:44:39 +0530 Subject: [PATCH 06/12] update tekon config Signed-off-by: Mangaal --- .tekton/gitops-backend-pull-request.yaml | 2 +- .tekton/gitops-backend-push.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.tekton/gitops-backend-pull-request.yaml b/.tekton/gitops-backend-pull-request.yaml index cf02ff4..548fabc 100644 --- a/.tekton/gitops-backend-pull-request.yaml +++ b/.tekton/gitops-backend-pull-request.yaml @@ -232,7 +232,7 @@ spec: - name: BUILD_ARGS_FILE value: $(params.build-args-file) - name: TARGET_VERSION - value: '{{target_branch}} + value: '{{target_branch}}' - name: SOURCE_ARTIFACT value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT) - name: CACHI2_ARTIFACT diff --git a/.tekton/gitops-backend-push.yaml b/.tekton/gitops-backend-push.yaml index 26b900a..4fcb25c 100644 --- a/.tekton/gitops-backend-push.yaml +++ b/.tekton/gitops-backend-push.yaml @@ -229,7 +229,7 @@ spec: - name: BUILD_ARGS_FILE value: $(params.build-args-file) - name: TARGET_VERSION - value: '{{target_branch}}' + value: '{{target_branch}}' - name: SOURCE_ARTIFACT value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT) - name: CACHI2_ARTIFACT From 432a0ad9e1ca882ab9c4f37be1b1df06d259725d Mon Sep 17 00:00:00 2001 From: Mangaal Date: Thu, 28 Nov 2024 12:46:05 +0530 Subject: [PATCH 07/12] remove extra space Signed-off-by: Mangaal --- .tekton/gitops-backend-pull-request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tekton/gitops-backend-pull-request.yaml b/.tekton/gitops-backend-pull-request.yaml index 548fabc..f7ec03a 100644 --- a/.tekton/gitops-backend-pull-request.yaml +++ b/.tekton/gitops-backend-pull-request.yaml @@ -232,7 +232,7 @@ spec: - name: BUILD_ARGS_FILE value: $(params.build-args-file) - name: TARGET_VERSION - value: '{{target_branch}}' + value: '{{target_branch}}' - name: SOURCE_ARTIFACT value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT) - name: CACHI2_ARTIFACT From 85454406deb553f63342b7c14476887bc9524480 Mon Sep 17 00:00:00 2001 From: Mangaal Date: Thu, 28 Nov 2024 12:48:15 +0530 Subject: [PATCH 08/12] fix ci error Signed-off-by: Mangaal --- .konflux/Containerfile.plugin | 1 - .tekton/gitops-backend-pull-request.yaml | 2 -- .tekton/gitops-backend-push.yaml | 2 -- 3 files changed, 5 deletions(-) diff --git a/.konflux/Containerfile.plugin b/.konflux/Containerfile.plugin index 5d6352a..881bf0b 100644 --- a/.konflux/Containerfile.plugin +++ b/.konflux/Containerfile.plugin @@ -15,7 +15,6 @@ ENTRYPOINT ["./backend-http"] LABEL \ name="openshift-gitops-1/gitops-rhel8" \ - version=${TARGET_VERSION} \ License="Apache 2.0" \ com.redhat.component="openshift-gitops-container" \ com.redhat.delivery.appregistry="false" \ diff --git a/.tekton/gitops-backend-pull-request.yaml b/.tekton/gitops-backend-pull-request.yaml index f7ec03a..79e4d4b 100644 --- a/.tekton/gitops-backend-pull-request.yaml +++ b/.tekton/gitops-backend-pull-request.yaml @@ -231,8 +231,6 @@ spec: - $(params.build-args[*]) - name: BUILD_ARGS_FILE value: $(params.build-args-file) - - name: TARGET_VERSION - value: '{{target_branch}}' - name: SOURCE_ARTIFACT value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT) - name: CACHI2_ARTIFACT diff --git a/.tekton/gitops-backend-push.yaml b/.tekton/gitops-backend-push.yaml index 4fcb25c..c5eb478 100644 --- a/.tekton/gitops-backend-push.yaml +++ b/.tekton/gitops-backend-push.yaml @@ -228,8 +228,6 @@ spec: - $(params.build-args[*]) - name: BUILD_ARGS_FILE value: $(params.build-args-file) - - name: TARGET_VERSION - value: '{{target_branch}}' - name: SOURCE_ARTIFACT value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT) - name: CACHI2_ARTIFACT From c600d96e822de7af0224ab25ccfc391c4d017fd9 Mon Sep 17 00:00:00 2001 From: Mangaal Date: Thu, 28 Nov 2024 13:08:58 +0530 Subject: [PATCH 09/12] check without hermetic Signed-off-by: Mangaal --- .tekton/gitops-backend-pull-request.yaml | 4 ---- .tekton/gitops-backend-push.yaml | 4 ---- 2 files changed, 8 deletions(-) diff --git a/.tekton/gitops-backend-pull-request.yaml b/.tekton/gitops-backend-pull-request.yaml index 79e4d4b..1f5316f 100644 --- a/.tekton/gitops-backend-pull-request.yaml +++ b/.tekton/gitops-backend-pull-request.yaml @@ -26,10 +26,6 @@ spec: value: quay.io/redhat-user-workloads/rh-openshift-gitops-tenant/openshift-gitops-operator/gitops-backend:on-pr-{{revision}} - name: image-expires-after value: 5d - - name: hermetic - value: "true" - - name: prefetch-input - value: '{"type": "gomod", "path": "."}' - name: build-platforms value: - linux/x86_64 diff --git a/.tekton/gitops-backend-push.yaml b/.tekton/gitops-backend-push.yaml index c5eb478..0e0da6c 100644 --- a/.tekton/gitops-backend-push.yaml +++ b/.tekton/gitops-backend-push.yaml @@ -23,10 +23,6 @@ spec: value: '{{revision}}' - name: output-image value: quay.io/redhat-user-workloads/rh-openshift-gitops-tenant/openshift-gitops-operator/gitops-backend:{{revision}} - - name: hermetic - value: "true" - - name: prefetch-input - value: '{"type": "gomod", "path": "."}' - name: build-platforms value: - linux/x86_64 From 18da3bfe3a7d9fc8437d91f04480a5afc80ee06b Mon Sep 17 00:00:00 2001 From: Mangaal Date: Thu, 28 Nov 2024 13:20:35 +0530 Subject: [PATCH 10/12] enable hermetic Signed-off-by: Mangaal --- .tekton/gitops-backend-pull-request.yaml | 4 ++++ .tekton/gitops-backend-push.yaml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.tekton/gitops-backend-pull-request.yaml b/.tekton/gitops-backend-pull-request.yaml index 1f5316f..c7a1483 100644 --- a/.tekton/gitops-backend-pull-request.yaml +++ b/.tekton/gitops-backend-pull-request.yaml @@ -31,6 +31,10 @@ spec: - linux/x86_64 - name: dockerfile value: .konflux/Containerfile.plugin + - name: hermetic + value: "true" + - name: prefetch-input + value: '{"type": "gomod", "path": "."}' pipelineSpec: description: | This pipeline is ideal for building multi-arch container images from a Containerfile while maintaining trust after pipeline customization. diff --git a/.tekton/gitops-backend-push.yaml b/.tekton/gitops-backend-push.yaml index 0e0da6c..a31f37c 100644 --- a/.tekton/gitops-backend-push.yaml +++ b/.tekton/gitops-backend-push.yaml @@ -28,6 +28,10 @@ spec: - linux/x86_64 - name: dockerfile value: .konflux/Containerfile.plugin + - name: hermetic + value: "true" + - name: prefetch-input + value: '{"type": "gomod", "path": "."}' pipelineSpec: description: | This pipeline is ideal for building multi-arch container images from a Containerfile while maintaining trust after pipeline customization. From c92ca9ace2e680ea079e209f68023a0280e89573 Mon Sep 17 00:00:00 2001 From: Mangaal Date: Thu, 28 Nov 2024 13:39:29 +0530 Subject: [PATCH 11/12] add toolchain Signed-off-by: Mangaal --- go.mod | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go.mod b/go.mod index 4279bf8..e8f9755 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/redhat-developer/gitops-backend go 1.22 +toolchain go1.22.5 + require ( github.com/argoproj/argo-cd v0.8.1-0.20210326223336-719d6a9c252e github.com/go-git/go-git/v5 v5.1.0 From 0053b515ce467f0f153c46cfdf9268ff9cce7a30 Mon Sep 17 00:00:00 2001 From: Mangaal Date: Wed, 4 Dec 2024 10:00:44 +0530 Subject: [PATCH 12/12] enable multi arch for push Signed-off-by: Mangaal --- .tekton/gitops-backend-push.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.tekton/gitops-backend-push.yaml b/.tekton/gitops-backend-push.yaml index a31f37c..46d2cd9 100644 --- a/.tekton/gitops-backend-push.yaml +++ b/.tekton/gitops-backend-push.yaml @@ -26,6 +26,9 @@ spec: - name: build-platforms value: - linux/x86_64 + - linux/arm64 + - linux/ppc64le + - linux/s390x - name: dockerfile value: .konflux/Containerfile.plugin - name: hermetic