From c2eda08c589875839be6d124234af2f7ef3a2485 Mon Sep 17 00:00:00 2001 From: idanovinda Date: Tue, 18 Nov 2025 17:27:46 +0100 Subject: [PATCH 1/8] separate pipeline for internal/external build and support multi arch --- Makefile | 26 ++++++++++++++++------ delivery.yaml | 55 +++++++++++++++++++++++++++++++---------------- docker/Dockerfile | 2 +- ui/Dockerfile | 2 +- ui/Makefile | 21 +++++++++++++----- 5 files changed, 75 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 50d070b9d..078fae28b 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,8 @@ LOCAL_BUILD_FLAGS ?= $(BUILD_FLAGS) LDFLAGS ?= -X=main.version=$(VERSION) DOCKERDIR = docker -IMAGE ?= registry.opensource.zalan.do/acid/$(BINARY) +BASE_IMAGE ?= alpine:latest +IMAGE ?= ghcr.io/zalando/$(BINARY) TAG ?= $(VERSION) GITHEAD = $(shell git rev-parse --short HEAD) GITURL = $(shell git config --get remote.origin.url) @@ -42,8 +43,9 @@ ifndef GOPATH GOPATH := $(HOME)/go endif -PATH := $(GOPATH)/bin:$(PATH) -SHELL := env PATH="$(PATH)" $(SHELL) +PATH := $(GOPATH)/bin:$(PATH) +SHELL := env PATH="$(PATH)" $(SHELL) +IMAGE_TAG := $(IMAGE):$(TAG)$(CDP_TAG)$(DEBUG_FRESH)$(DEBUG_POSTFIX) default: local @@ -66,13 +68,25 @@ docker: ${DOCKERDIR}/${DOCKERFILE} echo "Version ${VERSION}" echo "CDP tag ${CDP_TAG}" echo "git describe $(shell git describe --tags --always --dirty)" - docker build --rm -t "$(IMAGE):$(TAG)$(CDP_TAG)$(DEBUG_FRESH)$(DEBUG_POSTFIX)" -f "${DOCKERDIR}/${DOCKERFILE}" --build-arg VERSION="${VERSION}" . + docker build --rm -t "$(IMAGE_TAG)" -f "${DOCKERDIR}/${DOCKERFILE}" --build-arg VERSION="${VERSION}" --build-arg BASE_IMAGE="${BASE_IMAGE}" . indocker-race: docker run --rm -v "${GOPATH}":"${GOPATH}" -e GOPATH="${GOPATH}" -e RACE=1 -w ${PWD} golang:1.25.3 bash -c "make linux" -push: - docker push "$(IMAGE):$(TAG)$(CDP_TAG)" +docker-push: + echo `(env)` + echo "Tag ${TAG}" + echo "Version ${VERSION}" + echo "CDP tag ${CDP_TAG}" + echo "git describe $(shell git describe --tags --always --dirty)" + docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use + docker buildx build --platform "linux/amd64,linux/arm64" \ + --build-arg BASE_IMAGE="${BASE_IMAGE}" \ + --build-arg VERSION="${VERSION}" \ + -t "$(IMAGE_TAG)" \ + -f "${DOCKERDIR}/${DOCKERFILE}" \ + --push . + echo "$(IMAGE_TAG)" mocks: GO111MODULE=on go generate ./... diff --git a/delivery.yaml b/delivery.yaml index 7eacd769b..576ace7ea 100644 --- a/delivery.yaml +++ b/delivery.yaml @@ -1,6 +1,13 @@ version: "2017-09-20" + +build_env: &BUILD_ENV + BASE_IMAGE: container-registry.zalando.net/library/alpine-3.15 + MULTI_ARCH_REGISTRY: container-registry-test.zalando.net/acid + pipeline: - id: build-postgres-operator + env: + <<: *BUILD_ENV type: script vm_config: type: linux @@ -17,17 +24,21 @@ pipeline: - desc: Build Docker image cmd: | - IS_PR_BUILD=${CDP_PULL_REQUEST_NUMBER+"true"} - if [[ ${CDP_TARGET_BRANCH} == "master" && ${IS_PR_BUILD} != "true" ]] - then - IMAGE=registry-write.opensource.zalan.do/acid/postgres-operator + if [ -z ${CDP_SOURCE_BRANCH} ]; then + IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator else - IMAGE=registry-write.opensource.zalan.do/acid/postgres-operator-test + IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-test + fi + + IMAGE_TAG=$(make docker-push IMAGE=${IMAGE} BASE_IMAGE=${BASE_IMAGE}) + + if [ -z ${CDP_SOURCE_BRANCH} ]; then + cdp-promote-image ${IMAGE_TAG} fi - export IMAGE - make docker push - id: build-operator-ui + env: + <<: *BUILD_ENV type: script vm_config: type: linux @@ -46,18 +57,21 @@ pipeline: - desc: 'Build and push Docker image' cmd: | cd ui - IS_PR_BUILD=${CDP_PULL_REQUEST_NUMBER+"true"} - if [[ ${CDP_TARGET_BRANCH} == "master" && ${IS_PR_BUILD} != "true" ]] - then - IMAGE=registry-write.opensource.zalan.do/acid/postgres-operator-ui + if [ -z ${CDP_SOURCE_BRANCH} ]; then + IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-ui else - IMAGE=registry-write.opensource.zalan.do/acid/postgres-operator-ui-test + IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-ui-test + fi + + IMAGE_TAG=$(make docker-push IMAGE=${IMAGE} BASE_IMAGE=${BASE_IMAGE}) + + if [ -z ${CDP_SOURCE_BRANCH} ]; then + cdp-promote-image ${IMAGE_TAG} fi - export IMAGE - make docker - make push - id: build-logical-backup + env: + <<: *BUILD_ENV type: script vm_config: type: linux @@ -67,6 +81,11 @@ pipeline: cmd: | cd logical-backup export TAG=$(git describe --tags --always --dirty) - IMAGE="registry-write.opensource.zalan.do/acid/logical-backup" - docker build --rm -t "$IMAGE:$TAG$CDP_TAG" . - docker push "$IMAGE:$TAG$CDP_TAG" + docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use + docker buildx build --platform linux/amd64,linux/arm64 \ + -t ${MULTI_ARCH_REGISTRY}/postgres-operator-logical-backup:${TAG} \ + --push . + + if [ -z ${CDP_SOURCE_BRANCH} ]; then + cdp-promote-image ${MULTI_ARCH_REGISTRY}/postgres-operator-logical-backup:${TAG} + fi diff --git a/docker/Dockerfile b/docker/Dockerfile index e50380003..9eef4e68c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -ARG BASE_IMAGE=registry.opensource.zalan.do/library/alpine-3:latest +ARG BASE_IMAGE=alpine:latest FROM golang:1.25-alpine AS builder ARG VERSION=latest diff --git a/ui/Dockerfile b/ui/Dockerfile index 51f1d7744..8ed70c2c0 100644 --- a/ui/Dockerfile +++ b/ui/Dockerfile @@ -1,4 +1,4 @@ -ARG BASE_IMAGE=registry.opensource.zalan.do/library/python-3.11-slim:latest +ARG BASE_IMAGE=python:3.11-slim ARG NODE_IMAGE=node:lts-alpine FROM $NODE_IMAGE AS build diff --git a/ui/Makefile b/ui/Makefile index 8f88982ab..fe5da0e62 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -1,6 +1,7 @@ .PHONY: clean test appjs docker push mock -IMAGE ?= registry.opensource.zalan.do/acid/postgres-operator-ui +IMAGE ?= ghcr.io/zalando/postgres-operator-ui +BASE_IMAGE ?= alpine VERSION ?= $(shell git describe --tags --always --dirty) TAG ?= $(VERSION) GITHEAD = $(shell git rev-parse --short HEAD) @@ -30,10 +31,20 @@ docker: appjs echo "Version ${VERSION}" echo "CDP tag ${CDP_TAG}" echo "git describe $(shell git describe --tags --always --dirty)" - docker build --rm -t "$(IMAGE):$(TAG)$(CDP_TAG)" -f Dockerfile . - -push: - docker push "$(IMAGE):$(TAG)$(CDP_TAG)" + docker build --rm -t "$(IMAGE):$(TAG)$(CDP_TAG)" -f Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" . +docker-push: appjs + echo "Tag ${TAG}" + echo "Version ${VERSION}" + echo "CDP tag ${CDP_TAG}" + echo "git describe $(shell git describe --tags --always --dirty)" + docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use + docker buildx build --platform linux/amd64,linux/arm64 \ + --build-arg BASE_IMAGE="${BASE_IMAGE}" \ + -f Dockerfile \ + -t "$(IMAGE):$(TAG)$(CDP_TAG)" \ + --push . + echo "$(IMAGE):$(TAG)$(CDP_TAG)" + mock: docker run -it -p 8081:8081 "$(IMAGE):$(TAG)" --mock From 8769eccc33f7998bb4548300110c08f53f991dd4 Mon Sep 17 00:00:00 2001 From: inovindasari Date: Wed, 19 Nov 2025 15:26:52 +0100 Subject: [PATCH 2/8] remove distutils --- ui/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/Dockerfile b/ui/Dockerfile index 8ed70c2c0..19f748d82 100644 --- a/ui/Dockerfile +++ b/ui/Dockerfile @@ -17,7 +17,7 @@ WORKDIR /app RUN apt-get -qq -y update \ # https://www.psycopg.org/docs/install.html#psycopg-vs-psycopg-binary - && apt-get -qq -y install --no-install-recommends g++ libpq-dev python3-dev python3-distutils \ + && apt-get -qq -y install --no-install-recommends g++ libpq-dev python3-dev python3-setuptools \ && apt-get -qq -y clean \ && rm -rf /var/lib/apt/lists/* From 0441ffde383eef779dcf3cf9beb1706699b2b5c0 Mon Sep 17 00:00:00 2001 From: inovindasari Date: Wed, 19 Nov 2025 16:00:15 +0100 Subject: [PATCH 3/8] change base image arguments --- delivery.yaml | 8 +++++--- ui/Dockerfile | 2 +- ui/Makefile | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/delivery.yaml b/delivery.yaml index 576ace7ea..f51d53558 100644 --- a/delivery.yaml +++ b/delivery.yaml @@ -1,7 +1,9 @@ version: "2017-09-20" +allow_concurrent_steps: true build_env: &BUILD_ENV - BASE_IMAGE: container-registry.zalando.net/library/alpine-3.15 + PYTHON_BASE_IMAGE: container-registry.zalando.net/library/python-3.11-slim + ALPINE_BASE_IMAGE: container-registry.zalando.net/library/alpine-3.15 MULTI_ARCH_REGISTRY: container-registry-test.zalando.net/acid pipeline: @@ -30,7 +32,7 @@ pipeline: IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-test fi - IMAGE_TAG=$(make docker-push IMAGE=${IMAGE} BASE_IMAGE=${BASE_IMAGE}) + IMAGE_TAG=$(make docker-push IMAGE=${IMAGE} BASE_IMAGE=${ALPINE_BASE_IMAGE}) if [ -z ${CDP_SOURCE_BRANCH} ]; then cdp-promote-image ${IMAGE_TAG} @@ -63,7 +65,7 @@ pipeline: IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-ui-test fi - IMAGE_TAG=$(make docker-push IMAGE=${IMAGE} BASE_IMAGE=${BASE_IMAGE}) + IMAGE_TAG=$(make docker-push IMAGE=${IMAGE} BASE_IMAGE=${PYTHON_BASE_IMAGE} NODE_IMAGE=${ALPINE_BASE_IMAGE}) if [ -z ${CDP_SOURCE_BRANCH} ]; then cdp-promote-image ${IMAGE_TAG} diff --git a/ui/Dockerfile b/ui/Dockerfile index 19f748d82..8ed70c2c0 100644 --- a/ui/Dockerfile +++ b/ui/Dockerfile @@ -17,7 +17,7 @@ WORKDIR /app RUN apt-get -qq -y update \ # https://www.psycopg.org/docs/install.html#psycopg-vs-psycopg-binary - && apt-get -qq -y install --no-install-recommends g++ libpq-dev python3-dev python3-setuptools \ + && apt-get -qq -y install --no-install-recommends g++ libpq-dev python3-dev python3-distutils \ && apt-get -qq -y clean \ && rm -rf /var/lib/apt/lists/* diff --git a/ui/Makefile b/ui/Makefile index fe5da0e62..ae7c0c27d 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -31,7 +31,7 @@ docker: appjs echo "Version ${VERSION}" echo "CDP tag ${CDP_TAG}" echo "git describe $(shell git describe --tags --always --dirty)" - docker build --rm -t "$(IMAGE):$(TAG)$(CDP_TAG)" -f Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" . + docker build --rm -t "$(IMAGE):$(TAG)$(CDP_TAG)" -f Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg NODE_IMAGE="${NODE_IMAGE}" . docker-push: appjs echo "Tag ${TAG}" @@ -41,6 +41,7 @@ docker-push: appjs docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use docker buildx build --platform linux/amd64,linux/arm64 \ --build-arg BASE_IMAGE="${BASE_IMAGE}" \ + --build-arg NODE_IMAGE="${NODE_IMAGE}" \ -f Dockerfile \ -t "$(IMAGE):$(TAG)$(CDP_TAG)" \ --push . From 6d6746a9155c6d131df6e7e2d1c822860bc85599 Mon Sep 17 00:00:00 2001 From: inovindasari Date: Wed, 19 Nov 2025 16:05:48 +0100 Subject: [PATCH 4/8] use node:lts-alpine in both --- delivery.yaml | 2 +- ui/Makefile | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/delivery.yaml b/delivery.yaml index f51d53558..29a89e0d3 100644 --- a/delivery.yaml +++ b/delivery.yaml @@ -65,7 +65,7 @@ pipeline: IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-ui-test fi - IMAGE_TAG=$(make docker-push IMAGE=${IMAGE} BASE_IMAGE=${PYTHON_BASE_IMAGE} NODE_IMAGE=${ALPINE_BASE_IMAGE}) + IMAGE_TAG=$(make docker-push IMAGE=${IMAGE} BASE_IMAGE=${PYTHON_BASE_IMAGE}) if [ -z ${CDP_SOURCE_BRANCH} ]; then cdp-promote-image ${IMAGE_TAG} diff --git a/ui/Makefile b/ui/Makefile index ae7c0c27d..937cc2c5e 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -31,7 +31,7 @@ docker: appjs echo "Version ${VERSION}" echo "CDP tag ${CDP_TAG}" echo "git describe $(shell git describe --tags --always --dirty)" - docker build --rm -t "$(IMAGE):$(TAG)$(CDP_TAG)" -f Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg NODE_IMAGE="${NODE_IMAGE}" . + docker build --rm -t "$(IMAGE):$(TAG)$(CDP_TAG)" -f Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg . docker-push: appjs echo "Tag ${TAG}" @@ -41,7 +41,6 @@ docker-push: appjs docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use docker buildx build --platform linux/amd64,linux/arm64 \ --build-arg BASE_IMAGE="${BASE_IMAGE}" \ - --build-arg NODE_IMAGE="${NODE_IMAGE}" \ -f Dockerfile \ -t "$(IMAGE):$(TAG)$(CDP_TAG)" \ --push . From 218682886d9d143cd23dcdc63c5f3a7cce9381d1 Mon Sep 17 00:00:00 2001 From: inovindasari Date: Tue, 25 Nov 2025 14:01:18 +0100 Subject: [PATCH 5/8] fix local naming and base image --- Makefile | 2 +- ui/Makefile | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 078fae28b..4f0e207d7 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ LDFLAGS ?= -X=main.version=$(VERSION) DOCKERDIR = docker BASE_IMAGE ?= alpine:latest -IMAGE ?= ghcr.io/zalando/$(BINARY) +IMAGE ?= $(BINARY) TAG ?= $(VERSION) GITHEAD = $(shell git rev-parse --short HEAD) GITURL = $(shell git config --get remote.origin.url) diff --git a/ui/Makefile b/ui/Makefile index 937cc2c5e..70c2018db 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -1,7 +1,7 @@ .PHONY: clean test appjs docker push mock -IMAGE ?= ghcr.io/zalando/postgres-operator-ui -BASE_IMAGE ?= alpine +IMAGE ?= postgres-operator-ui +BASE_IMAGE ?= python:3.11-slim VERSION ?= $(shell git describe --tags --always --dirty) TAG ?= $(VERSION) GITHEAD = $(shell git rev-parse --short HEAD) @@ -31,7 +31,7 @@ docker: appjs echo "Version ${VERSION}" echo "CDP tag ${CDP_TAG}" echo "git describe $(shell git describe --tags --always --dirty)" - docker build --rm -t "$(IMAGE):$(TAG)$(CDP_TAG)" -f Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg . + docker build --rm -t "$(IMAGE):$(TAG)$(CDP_TAG)" -f Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" . docker-push: appjs echo "Tag ${TAG}" From 860bc0619ac79d9cb2e200879ba1a296c64f18e4 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Fri, 5 Dec 2025 14:17:02 +0100 Subject: [PATCH 6/8] lets test pipeline on PR --- .github/workflows/publish_ghcr_image.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish_ghcr_image.yaml b/.github/workflows/publish_ghcr_image.yaml index 78815783a..6240a8c82 100644 --- a/.github/workflows/publish_ghcr_image.yaml +++ b/.github/workflows/publish_ghcr_image.yaml @@ -6,6 +6,7 @@ env: IMAGE_NAME_UI: ${{ github.repository }}-ui on: + pull_request: push: tags: - '*' From 6a3e8091bc962aeb1a17825afb401b78ad71c3f0 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Fri, 5 Dec 2025 14:26:48 +0100 Subject: [PATCH 7/8] skip PR tagging --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4f0e207d7..3e2b90154 100644 --- a/Makefile +++ b/Makefile @@ -35,9 +35,9 @@ ifeq ($(FRESH),1) DEBUG_FRESH=$(shell date +"%H-%M-%S") endif -ifdef CDP_PULL_REQUEST_NUMBER - CDP_TAG := -${CDP_BUILD_VERSION} -endif +#ifdef CDP_PULL_REQUEST_NUMBER +# CDP_TAG := -${CDP_BUILD_VERSION} +#endif ifndef GOPATH GOPATH := $(HOME)/go From 88e3051b49aeac0c76b2ac35d921194d2560d21c Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Fri, 5 Dec 2025 16:40:15 +0100 Subject: [PATCH 8/8] ok then lets test after merging --- .github/workflows/publish_ghcr_image.yaml | 3 ++- Makefile | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish_ghcr_image.yaml b/.github/workflows/publish_ghcr_image.yaml index 6240a8c82..7bfb17a51 100644 --- a/.github/workflows/publish_ghcr_image.yaml +++ b/.github/workflows/publish_ghcr_image.yaml @@ -6,8 +6,9 @@ env: IMAGE_NAME_UI: ${{ github.repository }}-ui on: - pull_request: push: + branches: + - master tags: - '*' diff --git a/Makefile b/Makefile index 3e2b90154..4f0e207d7 100644 --- a/Makefile +++ b/Makefile @@ -35,9 +35,9 @@ ifeq ($(FRESH),1) DEBUG_FRESH=$(shell date +"%H-%M-%S") endif -#ifdef CDP_PULL_REQUEST_NUMBER -# CDP_TAG := -${CDP_BUILD_VERSION} -#endif +ifdef CDP_PULL_REQUEST_NUMBER + CDP_TAG := -${CDP_BUILD_VERSION} +endif ifndef GOPATH GOPATH := $(HOME)/go