From 5205cc31e99bba31a1d8649948d96c9bc135c1f6 Mon Sep 17 00:00:00 2001 From: Sunidhi-Gaonkar1 Date: Thu, 30 Jun 2022 12:26:11 +0530 Subject: [PATCH 1/4] Enable ppc64le image builds --- .github/workflows/devel_image.yml | 30 +++++++++++++++++++++++------- .github/workflows/promote.yml | 15 ++++++++------- .github/workflows/stage.yml | 11 +++++++++-- Makefile | 6 ++++-- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/.github/workflows/devel_image.yml b/.github/workflows/devel_image.yml index 5b33e46ac..5fcfd64e7 100644 --- a/.github/workflows/devel_image.yml +++ b/.github/workflows/devel_image.yml @@ -14,23 +14,39 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 + + # setup qemu and buildx + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - name: Install build dependencies run: | pip install build + # we will first build the image for x86 and load it on the host for testing - name: Build Image run: | - make container REPO=receptor TAG=devel + export CONTAINERCMD="docker buildx" + export EXTRA_OPTS="--platform linux/amd64 --load" + make container REPO=quay.io/ansible/receptor TAG=devel - name: Test Image - run: podman run --rm receptor:devel receptor --version + run: docker run --rm quay.io/ansible/receptor:devel receptor --version - - name: Push To Quay - uses: redhat-actions/push-to-registry@v2.1.1 + - name: Login To Quay + uses: docker/login-action@v2 with: - image: receptor - tags: devel - registry: quay.io/ansible/ username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_TOKEN }} + registry: quay.io/ansible/receptor + + # Since x86 image is built in previous step + # buildx will use cached image, hence overall time will not be affected + - name: Build Multiarch Image & Push To Quay + run: | + export CONTAINERCMD="docker buildx" + export EXTRA_OPTS="--platform linux/amd64,linux/ppc64le --push" + make container REPO=quay.io/ansible/receptor TAG=devel \ No newline at end of file diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml index 05eb4f4a7..3410b36a6 100644 --- a/.github/workflows/promote.yml +++ b/.github/workflows/promote.yml @@ -43,11 +43,12 @@ jobs: run: | echo ${{ secrets.QUAY_TOKEN }} | docker login quay.io -u ${{ secrets.QUAY_USER }} --password-stdin - - name: Re-tag and promote awx image - run: | - docker pull ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }} - docker tag ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }} quay.io/${{ github.repository }}:${{ github.event.release.tag_name }} - docker tag ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }} quay.io/${{ github.repository }}:latest - docker push quay.io/${{ github.repository }}:${{ github.event.release.tag_name }} - docker push quay.io/${{ github.repository }}:latest + - name: Copy Image to Quay + uses: akhilerm/tag-push-action@v2.0.0 + with: + src: ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }} + dst: | + quay.io/${{ github.repository }}:${{ github.event.release.tag_name }} + quay.io/${{ github.repository }}:latest + diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index 6c490b99e..f5be1ed77 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -49,6 +49,13 @@ jobs: - name: Install dependencies run: | python3 -m pip install build + + # setup qemu and buildx + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - name: Log in to registry run: | @@ -56,7 +63,7 @@ jobs: - name: Build container image run: | - make container CONTAINERCMD=docker REPO=ghcr.io/${{ github.repository_owner }}/receptor VERSION=v${{ github.event.inputs.version }} LATEST=yes + make container CONTAINERCMD="docker buildx" EXTRA_OPTS="--platform linux/amd64,linux/ppc64le --push" REPO=ghcr.io/${{ github.repository_owner }}/receptor VERSION=v${{ github.event.inputs.version }} LATEST=yes - name: Stage container image run: | @@ -69,4 +76,4 @@ jobs: -e version=${{ github.event.inputs.version }} \ -e repo=${{ github.repository_owner }}/receptor \ -e github_token=${{ secrets.GITHUB_TOKEN }} \ - -e target_commitish=${{ github.event.inputs.ref }} + -e target_commitish=${{ github.event.inputs.ref }} \ No newline at end of file diff --git a/Makefile b/Makefile index bdb1581b7..7e35132d9 100644 --- a/Makefile +++ b/Makefile @@ -124,7 +124,7 @@ $(RECEPTOR_PYTHON_WORKER_WHEEL): receptor-python-worker/README.md receptor-pytho @cd receptor-python-worker && python3 -m build --wheel # Container command can be docker or podman -CONTAINERCMD := podman +CONTAINERCMD ?= podman # Repo without tag REPO := quay.io/ansible/receptor @@ -133,12 +133,14 @@ TAG := $(subst +,-,$(VERSION)) # Set this to tag image as :latest in addition to :$(VERSION) LATEST := +EXTRA_OPTS ?= + container: .container-flag-$(VERSION) .container-flag-$(VERSION): $(RECEPTORCTL_WHEEL) $(RECEPTOR_PYTHON_WORKER_WHEEL) @tar --exclude-vcs-ignores -czf packaging/container/source.tar.gz . @cp $(RECEPTORCTL_WHEEL) packaging/container @cp $(RECEPTOR_PYTHON_WORKER_WHEEL) packaging/container - $(CONTAINERCMD) build packaging/container --build-arg VERSION=$(VERSION:v%=%) -t $(REPO):$(TAG) $(if $(LATEST),-t $(REPO):latest,) + $(CONTAINERCMD) build $(EXTRA_OPTS) packaging/container --build-arg VERSION=$(VERSION:v%=%) -t $(REPO):$(TAG) $(if $(LATEST),-t $(REPO):latest,) @touch .container-flag-$(VERSION) tc-image: container From 3616fb3d9d4716d03b7976acdefd30caa3eb7619 Mon Sep 17 00:00:00 2001 From: Shane McDonald Date: Tue, 9 Aug 2022 21:05:34 -0400 Subject: [PATCH 2/4] Enable ARM image builds --- .github/workflows/devel_image.yml | 2 +- .github/workflows/stage.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/devel_image.yml b/.github/workflows/devel_image.yml index 5fcfd64e7..783889ece 100644 --- a/.github/workflows/devel_image.yml +++ b/.github/workflows/devel_image.yml @@ -48,5 +48,5 @@ jobs: - name: Build Multiarch Image & Push To Quay run: | export CONTAINERCMD="docker buildx" - export EXTRA_OPTS="--platform linux/amd64,linux/ppc64le --push" + export EXTRA_OPTS="--platform linux/amd64,linux/ppc64le,linux/arm64 --push" make container REPO=quay.io/ansible/receptor TAG=devel \ No newline at end of file diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index f5be1ed77..e3d5bf87a 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -63,7 +63,7 @@ jobs: - name: Build container image run: | - make container CONTAINERCMD="docker buildx" EXTRA_OPTS="--platform linux/amd64,linux/ppc64le --push" REPO=ghcr.io/${{ github.repository_owner }}/receptor VERSION=v${{ github.event.inputs.version }} LATEST=yes + make container CONTAINERCMD="docker buildx" EXTRA_OPTS="--platform linux/amd64,linux/ppc64le,linux/arm64 --push" REPO=ghcr.io/${{ github.repository_owner }}/receptor VERSION=v${{ github.event.inputs.version }} LATEST=yes - name: Stage container image run: | From 5881d2364aa189bee40de2329743fdeb10dbf04a Mon Sep 17 00:00:00 2001 From: Shane McDonald Date: Sat, 13 Aug 2022 12:01:05 -0400 Subject: [PATCH 3/4] Push devel images to quay repo corresponding to github user/repo --- .github/workflows/devel_image.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/devel_image.yml b/.github/workflows/devel_image.yml index 783889ece..426312a46 100644 --- a/.github/workflows/devel_image.yml +++ b/.github/workflows/devel_image.yml @@ -1,6 +1,6 @@ --- -name: Publish quay.io/ansible/receptor:devel +name: Publish devel image on: push: @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - + # setup qemu and buildx - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -31,17 +31,17 @@ jobs: run: | export CONTAINERCMD="docker buildx" export EXTRA_OPTS="--platform linux/amd64 --load" - make container REPO=quay.io/ansible/receptor TAG=devel + make container REPO=quay.io/${{ github.repository }} TAG=devel - name: Test Image - run: docker run --rm quay.io/ansible/receptor:devel receptor --version + run: docker run --rm quay.io/${{ github.repository }}:devel receptor --version - name: Login To Quay uses: docker/login-action@v2 with: username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_TOKEN }} - registry: quay.io/ansible/receptor + registry: quay.io/${{ github.repository }} # Since x86 image is built in previous step # buildx will use cached image, hence overall time will not be affected @@ -49,4 +49,4 @@ jobs: run: | export CONTAINERCMD="docker buildx" export EXTRA_OPTS="--platform linux/amd64,linux/ppc64le,linux/arm64 --push" - make container REPO=quay.io/ansible/receptor TAG=devel \ No newline at end of file + make container REPO=quay.io/${{ github.repository }} TAG=devel From 53f2197b01a5033d440900b650cbf3b2e164102f Mon Sep 17 00:00:00 2001 From: Shane McDonald Date: Sun, 14 Aug 2022 11:47:47 -0400 Subject: [PATCH 4/4] Fix idempotency in Makefile when building container image Having the version targets under .PHONY was causing `make container` to build from scratch each time, even when the image was already built. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7e35132d9..bf7b7bc12 100644 --- a/Makefile +++ b/Makefile @@ -159,4 +159,4 @@ clean: @rm -rfv receptorctl-test-venv/ @rm -fv kubectl -.PHONY: lint format fmt pre-commit build-all test clean testloop container version receptorctl-tests kubetest receptorctl/.VERSION receptor-python-worker/.VERSION +.PHONY: lint format fmt pre-commit build-all test clean testloop container version receptorctl-tests kubetest