Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Improve operator image build #1963

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,24 @@ jobs:
go-version: 1.21.10
- name: Run unit tests
run: make test
image-build:
runs-on: ubuntu-22.04
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Build image
run: docker build .
multiplatform-image-build:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm']
runs-on: ${{matrix.runners}}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build images
uses: docker/build-push-action@v3
with:
file: Dockerfile
platforms: linux/amd64,linux/ppc64le,linux/arm64
tags: quay.io/eclipse/che-operator:next
- name: Set arch environment variable
run: |
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then
echo arch="amd64" >> $GITHUB_ENV
else
echo arch="arm64" >> $GITHUB_ENV
fi
- name: Build image
run: docker buildx build --platform linux/${{env.arch}} .
source-code-validation:
runs-on: ubuntu-22.04
steps:
Expand Down
67 changes: 51 additions & 16 deletions .github/workflows/release-next-catalog-and-operator-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,67 @@ on:
branches:
- main
jobs:
build-operator-image:
runs-on: ubuntu-22.04
build-operator-image-multiarch:
strategy:
fail-fast: false
matrix:
runners: ['ubuntu-22.04', 'ubuntu-22.04-arm']
runs-on: ${{matrix.runners}}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Install yq
run: sudo pip install yq
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set arch environment variable
run: |
if [[ ${{matrix.runners}} == 'ubuntu-22.04' ]]; then
echo arch="amd64" >> $GITHUB_ENV
else
echo arch="arm64" >> $GITHUB_ENV
fi
- name: Set short_sha environment variable
run: echo short_sha="$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Login to quay.io
uses: docker/login-action@v2
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
- name: Build operator image
uses: docker/build-push-action@v3
run: |
docker buildx build \
--platform linux/${{env.arch}} \
--progress=plain \
--push \
-t quay.io/eclipse/che-operator:${{env.arch}}-${{short_sha}} .

publish-operator-manifest:
name: publish operator image
runs-on: ubuntu-22.04
needs: build-operator-image-multiarch
steps:
- name: Login to Quay.io
uses: docker/login-action@v2
with:
file: Dockerfile
platforms: linux/amd64,linux/ppc64le,linux/arm64
push: true
tags: quay.io/eclipse/che-operator:next
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Set short_sha environment variable
run: echo short_sha="$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: publish
run: |
docker manifest create quay.io/eclipse/che-operator:next \
--amend quay.io/eclipse/che-operator:amd64-${{env.short_sha}} \
--amend quay.io/eclipse/che-operator:arm64-${{env.short_sha}}
docker manifest annotate quay.io/eclipse/che-operator:next \
quay.io/eclipse/che-operator:amd64-${{env.short_sha}} \
--os linux --arch amd64
docker manifest annotate quay.io/eclipse/che-operator:next \
quay.io/eclipse/che-operator:arm64-${{env.short_sha}} \
--os linux --arch arm64
docker manifest push quay.io/eclipse/che-operator:next

build-catalog:
runs-on: ubuntu-22.04
needs: build-operator-image
needs: publish-operator-manifest
steps:
- name: Checkout source code
uses: actions/checkout@v3
Expand All @@ -69,8 +103,9 @@ jobs:
${GITHUB_WORKSPACE}/build/scripts/olm/release-catalog.sh \
--channel next \
--image-tool docker \
--platform linux/amd64,linux/arm64,linux/ppc64le \
--platform linux/amd64,linux/arm64 \
--catalog-image quay.io/eclipse/eclipse-che-olm-catalog:next

build-catalog-with-digest:
runs-on: ubuntu-22.04
needs: build-operator-image
Expand Down Expand Up @@ -101,6 +136,6 @@ jobs:
${GITHUB_WORKSPACE}/build/scripts/olm/release-catalog.sh \
--channel next \
--image-tool docker \
--platform linux/amd64,linux/arm64,linux/ppc64le \
--platform linux/amd64,linux/arm64 \
--catalog-image quay.io/eclipse/eclipse-che-olm-catalog:next-digest \
--bundle-image quay.io/eclipse/eclipse-che-olm-bundle:$(make bundle-version CHANNEL=next)-digest
2 changes: 1 addition & 1 deletion build/scripts/release/make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ init() {
PREPARE_COMMUNITY_OPERATORS_UPDATE=false
OPERATOR_REPO=$(dirname "$(dirname "$(dirname "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")")")
FORCE_UPDATE=""
BUILDX_PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64"
BUILDX_PLATFORMS="linux/amd64,linux/arm64"
CSV_STABLE_PATH=$(make csv-path CHANNEL=stable)
MANAGER_YAML=${OPERATOR_REPO}/config/manager/manager.yaml
CHE_OPERATOR_IMAGE=$(yq -r '.spec.template.spec.containers[0].image' "${MANAGER_YAML}" | sed -e "s/\(.*:\).*/\1${RELEASE}/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ metadata:
operatorframework.io/arch.amd64: supported
operatorframework.io/arch.arm64: supported
operatorframework.io/os.linux: supported
name: eclipse-che.v7.99.0-898.next
name: eclipse-che.v7.99.0-899.next
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -1077,7 +1077,7 @@ spec:
minKubeVersion: 1.19.0
provider:
name: Eclipse Foundation
version: 7.99.0-898.next
version: 7.99.0-899.next
webhookdefinitions:
- admissionReviewVersions:
- v1
Expand Down
Loading