Skip to content

Commit

Permalink
Publish multi-arch container images (#101)
Browse files Browse the repository at this point in the history
* Multi-arch publish

This PR introduces a PR, to build & publish
ARM64 & AMD64 container images to quay.io/cloud-bulldozer/netperf

Signed-off-by: Krishna Harsha Voora <[email protected]>

* Bifurcate the GitHub Actions

* Updates the container image flow

* Trigger only when Dockerfile changes

---------

Signed-off-by: Krishna Harsha Voora <[email protected]>
  • Loading branch information
krishvoor authored Aug 28, 2023
1 parent 589d4ec commit fef9a09
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 3 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release k8s-netperf container image

on:
pull_request:
paths:
- 'containers/Dockerfile' # Trigger only when Dockerfile changes in a pull request

env:
CONTAINER_REGISTRY: ${{ github.repository_owner == 'cloud-bulldozer' && 'quay.io' }}
RHEL_VERSION: ubi9
GO_VER: 1.19

jobs:

build-and-push-container-images:
name: Build and Push Container Images
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup docker-buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
config-inline: |
[worker.oci]
max-parallelism = 1
- name: Checkout
uses: actions/checkout@v3

- name: Login to the ${{ env.CONTAINER_REGISTRY }} Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ env.CONTAINER_REGISTRY == 'quay.io' && secrets.QUAY_IO_USERNAME || github.actor }}
password: ${{ env.CONTAINER_REGISTRY == 'quay.io' && secrets.QUAY_IO_TOKEN || secrets.GITHUB_TOKEN }

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.CONTAINER_REGISTRY }}/${{ github.repository_owner }}/netperf
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
- name: Build and push multi-arch Image
id: push
uses: docker/build-push-action@v3
with:
file: containers/Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
RHEL_VERSION=${{ env.RHEL_VERSION }}
GO_VER=${{ env.GO_VER }}
GO_TAGS=
10 changes: 7 additions & 3 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ on:
tags:
- "*" # triggers only if push new tag version

env:
CONTAINER_REGISTRY: ${{ github.repository_owner == 'cloud-bulldozer' && 'quay.io' }}
GO_VER: 1.19

jobs:
build:
build-binaries:
name: GoReleaser build
runs-on: ubuntu-latest

Expand All @@ -16,10 +20,10 @@ jobs:
with:
fetch-depth: 0

- name: Set up Go 1.19
- name: Set up Go ${{ env.GO_VER }}
uses: actions/setup-go@v2
with:
go-version: 1.19
go-version: ${{ env.GO_VER }}
id: go

- name: Run GoReleaser
Expand Down

0 comments on commit fef9a09

Please sign in to comment.