Skip to content

Commit

Permalink
Merge pull request #574 from cyclinder/multi_image
Browse files Browse the repository at this point in the history
Add multi-arch docker image support
  • Loading branch information
SchSeba committed Mar 18, 2024
2 parents 1fac942 + 542a820 commit f9a5002
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 48 deletions.
83 changes: 61 additions & 22 deletions .github/workflows/image-push-master.yml
Original file line number Diff line number Diff line change
@@ -1,89 +1,128 @@
name: "Push images on merge to master"

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le

on:
push:
branches:
- master

jobs:
build-and-push-image-operator:
runs-on: ubuntu-20.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3

# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Docker
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}

- name: Build and push sriov-network-operator
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ env.BUILD_PLATFORMS }}
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./Dockerfile

build-and-push-image-config-daemon:
runs-on: ubuntu-20.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}-config-daemon
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3

# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Docker
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}-config-daemon

- name: Build and push sriov-network-operator-config-daemon
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ env.BUILD_PLATFORMS }}
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
${{ env.IMAGE_NAME }}-config-daemon:latest
${{ env.IMAGE_NAME }}-config-daemon:${{ github.sha }}
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./Dockerfile.sriov-network-config-daemon

build-and-push-image-webhook:
runs-on: ubuntu-20.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}-webhook
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3

# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Docker
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}-webhook

- name: Build and push sriov-network-operator-webhook
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ env.BUILD_PLATFORMS }}
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
${{ env.IMAGE_NAME }}-webhook:latest
${{ env.IMAGE_NAME }}-webhook:${{ github.sha }}
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./Dockerfile.webhook
75 changes: 49 additions & 26 deletions .github/workflows/image-push-release.yml
Original file line number Diff line number Diff line change
@@ -1,107 +1,130 @@
name: "Push images on release"

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le

on:
push:
tags:
- v*
jobs:
build-and-push-image-operator:
runs-on: ubuntu-20.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3

# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Docker
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
tag-latest: false
flavor: |
latest=false
- name: Build and push sriov-network-operator
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ env.BUILD_PLATFORMS }}
tags: |
${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./Dockerfile

build-and-push-image-config-daemon:
runs-on: ubuntu-20.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}-config-daemon
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3

# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Docker
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
tag-latest: false
images: ${{ env.IMAGE_NAME }}-config-daemon
flavor: |
latest=false
- name: Build and push sriov-network-operator-config-daemon
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ env.BUILD_PLATFORMS }}
tags: |
${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./Dockerfile.sriov-network-config-daemon

build-and-push-image-webhook:
runs-on: ubuntu-20.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}-webhook
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3

# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Docker
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
tag-latest: false
images: ${{ env.IMAGE_NAME }}-webhook
flavor: |
latest=false
- name: Build and push sriov-network-operator-webhook
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ env.BUILD_PLATFORMS }}
tags: |
${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./Dockerfile.webhook

0 comments on commit f9a5002

Please sign in to comment.