Skip to content

Commit 62b1df1

Browse files
authored
chore: Improve operator image build (#1963)
* chore: Improve operator image build Signed-off-by: Anatolii Bazko <abazko@redhat.com>
1 parent 4ae191d commit 62b1df1

File tree

4 files changed

+68
-37
lines changed

4 files changed

+68
-37
lines changed

.github/workflows/pr-check.yml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,24 @@ jobs:
2424
go-version: 1.21.10
2525
- name: Run unit tests
2626
run: make test
27-
image-build:
28-
runs-on: ubuntu-22.04
29-
steps:
30-
- name: Checkout source code
31-
uses: actions/checkout@v3
32-
- name: Build image
33-
run: docker build .
3427
multiplatform-image-build:
35-
runs-on: ubuntu-22.04
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm']
32+
runs-on: ${{matrix.runners}}
3633
steps:
3734
- name: Checkout source code
3835
uses: actions/checkout@v3
39-
- name: Set up QEMU
40-
uses: docker/setup-qemu-action@v3
41-
- name: Set up Docker Buildx
42-
uses: docker/setup-buildx-action@v3
43-
- name: Build images
44-
uses: docker/build-push-action@v3
45-
with:
46-
file: Dockerfile
47-
platforms: linux/amd64,linux/ppc64le,linux/arm64
48-
tags: quay.io/eclipse/che-operator:next
36+
- name: Set arch environment variable
37+
run: |
38+
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then
39+
echo arch="amd64" >> $GITHUB_ENV
40+
else
41+
echo arch="arm64" >> $GITHUB_ENV
42+
fi
43+
- name: Build image
44+
run: docker buildx build --platform linux/${{env.arch}} .
4945
source-code-validation:
5046
runs-on: ubuntu-22.04
5147
steps:

.github/workflows/release-next-catalog-and-operator-image.yaml

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,67 @@ on:
2222
branches:
2323
- main
2424
jobs:
25-
build-operator-image:
26-
runs-on: ubuntu-22.04
25+
build-operator-image-multiarch:
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm']
30+
runs-on: ${{matrix.runners}}
2731
steps:
2832
- name: Checkout source code
2933
uses: actions/checkout@v3
30-
- name: Install yq
31-
run: sudo pip install yq
32-
- name: Set up QEMU
33-
uses: docker/setup-qemu-action@v3
34-
- name: Set up Docker Buildx
35-
uses: docker/setup-buildx-action@v3
34+
- name: Set arch environment variable
35+
run: |
36+
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then
37+
echo arch="amd64" >> $GITHUB_ENV
38+
else
39+
echo arch="arm64" >> $GITHUB_ENV
40+
fi
41+
- name: Set short_sha environment variable
42+
run: echo short_sha="$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
3643
- name: Login to quay.io
3744
uses: docker/login-action@v2
3845
with:
3946
username: ${{ secrets.QUAY_USERNAME }}
4047
password: ${{ secrets.QUAY_PASSWORD }}
4148
registry: quay.io
4249
- name: Build operator image
43-
uses: docker/build-push-action@v3
50+
run: |
51+
docker buildx build \
52+
--platform linux/${{env.arch}} \
53+
--progress=plain \
54+
--push \
55+
-t quay.io/eclipse/che-operator:${{env.arch}}-${{short_sha}} .
56+
57+
publish-operator-manifest:
58+
name: publish operator image
59+
runs-on: ubuntu-22.04
60+
needs: build-operator-image-multiarch
61+
steps:
62+
- name: Login to Quay.io
63+
uses: docker/login-action@v2
4464
with:
45-
file: Dockerfile
46-
platforms: linux/amd64,linux/ppc64le,linux/arm64
47-
push: true
48-
tags: quay.io/eclipse/che-operator:next
65+
registry: quay.io
66+
username: ${{ secrets.QUAY_USERNAME }}
67+
password: ${{ secrets.QUAY_PASSWORD }}
68+
- name: Set short_sha environment variable
69+
run: echo short_sha="$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
70+
- name: publish
71+
run: |
72+
docker manifest create quay.io/eclipse/che-operator:next \
73+
--amend quay.io/eclipse/che-operator:amd64-${{env.short_sha}} \
74+
--amend quay.io/eclipse/che-operator:arm64-${{env.short_sha}}
75+
docker manifest annotate quay.io/eclipse/che-operator:next \
76+
quay.io/eclipse/che-operator:amd64-${{env.short_sha}} \
77+
--os linux --arch amd64
78+
docker manifest annotate quay.io/eclipse/che-operator:next \
79+
quay.io/eclipse/che-operator:arm64-${{env.short_sha}} \
80+
--os linux --arch arm64
81+
docker manifest push quay.io/eclipse/che-operator:next
82+
4983
build-catalog:
5084
runs-on: ubuntu-22.04
51-
needs: build-operator-image
85+
needs: publish-operator-manifest
5286
steps:
5387
- name: Checkout source code
5488
uses: actions/checkout@v3
@@ -69,8 +103,9 @@ jobs:
69103
${GITHUB_WORKSPACE}/build/scripts/olm/release-catalog.sh \
70104
--channel next \
71105
--image-tool docker \
72-
--platform linux/amd64,linux/arm64,linux/ppc64le \
106+
--platform linux/amd64,linux/arm64 \
73107
--catalog-image quay.io/eclipse/eclipse-che-olm-catalog:next
108+
74109
build-catalog-with-digest:
75110
runs-on: ubuntu-22.04
76111
needs: build-operator-image
@@ -101,6 +136,6 @@ jobs:
101136
${GITHUB_WORKSPACE}/build/scripts/olm/release-catalog.sh \
102137
--channel next \
103138
--image-tool docker \
104-
--platform linux/amd64,linux/arm64,linux/ppc64le \
139+
--platform linux/amd64,linux/arm64 \
105140
--catalog-image quay.io/eclipse/eclipse-che-olm-catalog:next-digest \
106141
--bundle-image quay.io/eclipse/eclipse-che-olm-bundle:$(make bundle-version CHANNEL=next)-digest

build/scripts/release/make-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ init() {
2828
PREPARE_COMMUNITY_OPERATORS_UPDATE=false
2929
OPERATOR_REPO=$(dirname "$(dirname "$(dirname "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")")")
3030
FORCE_UPDATE=""
31-
BUILDX_PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64"
31+
BUILDX_PLATFORMS="linux/amd64,linux/arm64"
3232
CSV_STABLE_PATH=$(make csv-path CHANNEL=stable)
3333
MANAGER_YAML=${OPERATOR_REPO}/config/manager/manager.yaml
3434
CHE_OPERATOR_IMAGE=$(yq -r '.spec.template.spec.containers[0].image' "${MANAGER_YAML}" | sed -e "s/\(.*:\).*/\1${RELEASE}/")

bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ metadata:
108108
operatorframework.io/arch.amd64: supported
109109
operatorframework.io/arch.arm64: supported
110110
operatorframework.io/os.linux: supported
111-
name: eclipse-che.v7.99.0-898.next
111+
name: eclipse-che.v7.99.0-899.next
112112
namespace: placeholder
113113
spec:
114114
apiservicedefinitions: {}
@@ -1077,7 +1077,7 @@ spec:
10771077
minKubeVersion: 1.19.0
10781078
provider:
10791079
name: Eclipse Foundation
1080-
version: 7.99.0-898.next
1080+
version: 7.99.0-899.next
10811081
webhookdefinitions:
10821082
- admissionReviewVersions:
10831083
- v1

0 commit comments

Comments
 (0)