Skip to content

Commit 83d1a6c

Browse files
Merge pull request #575 from darkdoc/multiarch_console
multiarch console
2 parents 2de5e45 + d7b71be commit 83d1a6c

8 files changed

Lines changed: 98 additions & 33 deletions

File tree

.github/workflows/build-push.yaml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ permissions:
1414
env:
1515
REGISTRY: localhost
1616
NAME: patterns-operator
17+
CONSOLE_NAME: patterns-operator-console
1718
TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || (github.ref_name == 'main' && 'latest' || github.ref_name) }}
1819

1920
jobs:
@@ -61,8 +62,41 @@ jobs:
6162
path: /tmp/image-${{ matrix.targetarch }}.tar
6263
retention-days: 1
6364

65+
build-console:
66+
strategy:
67+
matrix:
68+
include:
69+
- targetarch: amd64
70+
runner: ubuntu-latest
71+
- targetarch: arm64
72+
runner: ubuntu-24.04-arm
73+
74+
runs-on: ${{ matrix.runner }}
75+
permissions:
76+
contents: read
77+
steps:
78+
- name: Checkout repository
79+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
80+
with:
81+
persist-credentials: false
82+
83+
- name: Build console container image and save tarball
84+
env:
85+
TARGETARCH: ${{ matrix.targetarch }}
86+
CONSOLE_PLUGIN_IMAGE: ${{ env.CONSOLE_NAME }}:${{ env.TAG }}
87+
run: |
88+
make "console-build-${TARGETARCH}"
89+
buildah push "${CONSOLE_PLUGIN_IMAGE}-${TARGETARCH}" "docker-archive:/tmp/console-image-${TARGETARCH}.tar:${CONSOLE_PLUGIN_IMAGE}-${TARGETARCH}"
90+
91+
- name: Upload image artifact
92+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
93+
with:
94+
name: console-image-${{ matrix.targetarch }}-${{ github.run_id }}
95+
path: /tmp/console-image-${{ matrix.targetarch }}.tar
96+
retention-days: 1
97+
6498
pre-push-check:
65-
needs: [build-container]
99+
needs: [build-container, build-console]
66100
if: github.event_name != 'pull_request'
67101
runs-on: ubuntu-latest
68102
steps:
@@ -115,10 +149,24 @@ jobs:
115149
name: image-arm64-${{ github.run_id }}
116150
path: /tmp
117151

152+
- name: Download console AMD64 image
153+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
154+
with:
155+
name: console-image-amd64-${{ github.run_id }}
156+
path: /tmp
157+
158+
- name: Download console ARM64 image
159+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
160+
with:
161+
name: console-image-arm64-${{ github.run_id }}
162+
path: /tmp
163+
118164
- name: Load tarballs into local containers-storage
119165
run: |
120166
buildah pull docker-archive:/tmp/image-amd64.tar
121167
buildah pull docker-archive:/tmp/image-arm64.tar
168+
buildah pull docker-archive:/tmp/console-image-amd64.tar
169+
buildah pull docker-archive:/tmp/console-image-arm64.tar
122170
123171
- name: Log into Quay
124172
env:
@@ -134,13 +182,20 @@ jobs:
134182
env:
135183
UPLOADREGISTRY: ${{ matrix.upload_registry }}
136184
OPERATOR_IMG: ${{ env.NAME }}:${{ env.TAG }}
185+
CONSOLE_PLUGIN_IMAGE: ${{ env.CONSOLE_NAME }}:${{ env.TAG }}
137186
run: |
138187
make buildah-manifest
139188
buildah manifest add --arch=amd64 "${REGISTRY}/${OPERATOR_IMG}" "${REGISTRY}/${OPERATOR_IMG}-amd64"
140189
buildah manifest add --arch=arm64 "${REGISTRY}/${OPERATOR_IMG}" "${REGISTRY}/${OPERATOR_IMG}-arm64"
141190
make buildah-push
142191
DIGEST=$(skopeo inspect --format "{{.Digest}}" "docker://${UPLOADREGISTRY}/${OPERATOR_IMG}")
143192
echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"
193+
make console-multiarch-manifest
194+
buildah manifest add --arch=arm64 "${REGISTRY}/${CONSOLE_PLUGIN_IMAGE}" "${REGISTRY}/${CONSOLE_PLUGIN_IMAGE}-arm64"
195+
buildah manifest add --arch=amd64 "${REGISTRY}/${CONSOLE_PLUGIN_IMAGE}" "${REGISTRY}/${CONSOLE_PLUGIN_IMAGE}-amd64"
196+
make console-push
197+
CONSOLE_DIGEST=$(skopeo inspect --format "{{.Digest}}" "docker://${UPLOADREGISTRY}/${CONSOLE_PLUGIN_IMAGE}")
198+
echo "console_digest=$CONSOLE_DIGEST" >> "$GITHUB_OUTPUT"
144199
145200
- name: Install cosign
146201
uses: sigstore/cosign-installer@cad07c2e89fa2edd6e2d7bab4c1aa38e53f76003 # v4.1.1
@@ -152,8 +207,11 @@ jobs:
152207
- name: Sign the published Docker image
153208
env:
154209
DIGEST: ${{ steps.manifest-push.outputs.digest }}
210+
CONSOLE_DIGEST: ${{ steps.manifest-push.outputs.console_digest }}
155211
UPLOADREGISTRY: ${{ matrix.upload_registry }}
156212
OPERATOR_IMG: ${{ env.NAME }}:${{ env.TAG }}
213+
CONSOLE_PLUGIN_IMAGE: ${{ env.CONSOLE_NAME }}:${{ env.TAG }}
157214
run: |
158215
cat "${XDG_RUNTIME_DIR}/containers/auth.json" > ~/.docker/config.json
159216
cosign sign --yes "${UPLOADREGISTRY}/${OPERATOR_IMG}@${DIGEST}"
217+
cosign sign --yes "${UPLOADREGISTRY}/${CONSOLE_PLUGIN_IMAGE}@${CONSOLE_DIGEST}"

.github/workflows/console.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
persist-credentials: false
2222
- name: Build the console container
2323
run: |
24-
make console-build
24+
make console-build-amd64

Makefile

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ IMAGE_TAG_BASE ?= $(UPLOADREGISTRY)/$(OPERATOR_NAME)-operator
6969
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
7070

7171
# Image URL to use all building/pushing image targets
72-
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
72+
export IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
7373
OPERATOR_IMG ?= $(OPERATOR_NAME)-operator:$(VERSION)
7474

7575
# always release the console with the same tag as the operator and the other way around!
7676
# Image base URL of the console plugin
77-
CONSOLE_PLUGIN_IMAGE_BASE ?= $(IMAGE_TAG_BASE)-console
78-
CONSOLE_PLUGIN_IMAGE ?= $(CONSOLE_PLUGIN_IMAGE_BASE):$(VERSION)
77+
CONSOLE_PLUGIN_IMAGE_BASE ?= $(OPERATOR_NAME)-operator-console
78+
export CONSOLE_PLUGIN_IMAGE ?= $(CONSOLE_PLUGIN_IMAGE_BASE):$(VERSION)
7979
CONSOLE_PLUGIN_DOCKERFILE ?= console-plugin.Dockerfile
8080

8181
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
@@ -306,9 +306,7 @@ endef
306306
.PHONY: bundle
307307
bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
308308
$(OPERATOR_SDK) generate kustomize manifests -q
309-
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
310-
cd config/console-plugin && $(KUSTOMIZE) edit set image console-plugin=$(CONSOLE_PLUGIN_IMAGE)
311-
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
309+
$(KUSTOMIZE) build config/manifests | envsubst | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
312310
$(MAKE) bundle-fixes bundle-date
313311
./hack/set_openshift_minimum_version.sh
314312
$(OPERATOR_SDK) bundle validate ./bundle
@@ -359,22 +357,6 @@ ifneq ($(origin CATALOG_BASE_IMG), undefined)
359357
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
360358
endif
361359

362-
# Generate Dockerfile using the template. It uses envsubst to replace the value of the version label in the container
363-
.PHONY: generate-dockerfile-console-plugin
364-
generate-dockerfile-console-plugin:
365-
VERSION=$(VERSION) SUPPORTED_OCP_VERSIONS=$(SUPPORTED_OCP_VERSIONS) envsubst < templates/console-plugin.Dockerfile.template > $(CONSOLE_PLUGIN_DOCKERFILE)
366-
367-
.PHONY: console-build
368-
console-build: generate-dockerfile-console-plugin ## Build the console image
369-
@echo "Building console image with cache optimization..."
370-
@podman pull $(CONSOLE_PLUGIN_IMAGE_BASE):latest 2>/dev/null || true
371-
podman build -f $(CURPATH)/$(CONSOLE_PLUGIN_DOCKERFILE) -t ${CONSOLE_PLUGIN_IMAGE} .
372-
podman tag ${CONSOLE_PLUGIN_IMAGE} $(CONSOLE_PLUGIN_IMAGE_BASE):latest
373-
374-
.PHONY: console-push
375-
console-push: ## Push the console image
376-
podman push $(CONSOLE_PLUGIN_IMAGE)
377-
378360
# Build an OLM catalog image by adding the bundle image to a simple catalog using the
379361
# operator package manager tool, 'opm'. For more information see:
380362
# https://olm.operatorframework.io/docs/reference/catalog-templates
@@ -417,3 +399,32 @@ super-linter: ## Runs super linter locally
417399
-v $(PWD):/tmp/lint:rw,z \
418400
-w /tmp/lint \
419401
ghcr.io/super-linter/super-linter@sha256:6c71bd17ab38ceb7acb5b93ef72f5c2288b5456a5c82693ded3ee8bb501bba7f # slim-v8.1.0
402+
403+
##@ Console plugin tasks
404+
# Generate Dockerfile using the template. It uses envsubst to replace the value of the version label in the container
405+
.PHONY: generate-dockerfile-console-plugin
406+
generate-dockerfile-console-plugin:
407+
VERSION=$(VERSION) SUPPORTED_OCP_VERSIONS=$(SUPPORTED_OCP_VERSIONS) envsubst < templates/console-plugin.Dockerfile.template > $(CONSOLE_PLUGIN_DOCKERFILE)
408+
409+
.PHONY: console-multiarch-manifest
410+
console-multiarch-manifest: ## creates the buildah manifest for multi-arch images
411+
# The rm is needed due to bug https://www.github.com/containers/podman/issues/19757
412+
buildah manifest rm "${REGISTRY}/${CONSOLE_PLUGIN_IMAGE}" || /bin/true
413+
buildah manifest create "${REGISTRY}/${CONSOLE_PLUGIN_IMAGE}"
414+
415+
.PHONY: console-build-amd64
416+
console-build-amd64: generate-dockerfile-console-plugin console-multiarch-manifest ## build the console in amd64
417+
@echo "Building the console amd64"
418+
buildah build --platform linux/amd64 --format docker -f $(CONSOLE_PLUGIN_DOCKERFILE) -t "${CONSOLE_PLUGIN_IMAGE}-amd64"
419+
buildah manifest add --arch=amd64 "${REGISTRY}/${CONSOLE_PLUGIN_IMAGE}" "${REGISTRY}/${CONSOLE_PLUGIN_IMAGE}-amd64"
420+
421+
.PHONY: console-build-arm64
422+
console-build-arm64: generate-dockerfile-console-plugin console-multiarch-manifest ## build the console in amd64
423+
@echo "Building the console arm64"
424+
buildah build --platform linux/arm64 --format docker -f $(CONSOLE_PLUGIN_DOCKERFILE) -t "${CONSOLE_PLUGIN_IMAGE}-arm64"
425+
buildah manifest add --arch=arm64 "${REGISTRY}/${CONSOLE_PLUGIN_IMAGE}" "${REGISTRY}/${CONSOLE_PLUGIN_IMAGE}-arm64"
426+
427+
.PHONY: console-push
428+
console-push: ## Uploads the container to quay.io/validatedpatterns/${CONSOLE_PLUGIN_IMAGE}
429+
@echo "Uploading the ${REGISTRY}/${CONSOLE_PLUGIN_IMAGE} container to ${UPLOADREGISTRY}/${CONSOLE_PLUGIN_IMAGE}"
430+
buildah manifest push --all "${REGISTRY}/${CONSOLE_PLUGIN_IMAGE}" "docker://${UPLOADREGISTRY}/${CONSOLE_PLUGIN_IMAGE}"

config/console-plugin/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spec:
2020
app.kubernetes.io/component: patterns-operator-console-plugin
2121
spec:
2222
containers:
23-
- image: console-plugin
23+
- image: ${CONSOLE_PLUGIN_IMAGE}
2424
name: patterns-operator-console-plugin
2525
env:
2626
- name: OPERATOR_NAMESPACE

config/console-plugin/kustomization.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,3 @@ resources:
55
- service.yaml
66
- deployment.yaml
77
- configmap.yaml
8-
images:
9-
- name: console-plugin
10-
newName: kuemper.int.rhx/bandini/patterns-operator-console
11-
newTag: 6.6.6

config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ spec:
3131
- /manager
3232
args:
3333
- --leader-elect
34-
image: controller:latest
34+
image: ${IMG}
3535
name: manager
3636
securityContext:
3737
allowPrivilegeEscalation: false

hack/operator-build-deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ if [ $ret -ne 0 ]; then
7575
fi
7676

7777
make VERSION=${VERSION} UPLOADREGISTRY="${UPLOADREGISTRY}" CHANNELS=fast USE_IMAGE_DIGESTS="" \
78-
manifests bundle generate docker-build docker-push console-build console-push bundle-build bundle-push catalog-build \
78+
manifests bundle generate docker-build docker-push console-build-amd64 console-push bundle-build bundle-push catalog-build \
7979
catalog-push catalog-install
8080

8181
# If the operator already exists in openshift-operators, keep using that namespace;

templates/console-plugin.Dockerfile.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.access.redhat.com/ubi10/nodejs-22:latest AS build
1+
FROM registry.access.redhat.com/ubi9/nodejs-22:latest AS build
22
USER root
33
RUN command -v yarn || npm i -g yarn
44

@@ -8,7 +8,7 @@ COPY console/ .
88
RUN sed -r -i "s|\"version\": \"0.0.1\"|\"version\": \"${VERSION}\"|;" ./package.json
99
RUN yarn install && yarn build
1010

11-
FROM registry.access.redhat.com/ubi10/nginx-126:latest
11+
FROM registry.access.redhat.com/ubi9/nginx-126:latest
1212
LABEL \
1313
com.redhat.openshift.versions="${SUPPORTED_OCP_VERSIONS}" \
1414
com.redhat.component="Console plugin image for OpenShift Pattern Operator" \

0 commit comments

Comments
 (0)