Skip to content

Commit e066bff

Browse files
committed
Refactor CI workflows for multi-arch image builds
Signed-off-by: Ashok Pariya <[email protected]>
1 parent ce2f72c commit e066bff

File tree

3 files changed

+24
-195
lines changed

3 files changed

+24
-195
lines changed

.github/workflows/image-push-master.yaml

Lines changed: 7 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,16 @@ name: "push images on merge to master"
22

33
env:
44
IMAGE_NAME: ghcr.io/${{ github.repository }}
5+
PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
56

67
on:
78
push:
89
branches:
910
- master
10-
jobs:
11-
build-and-push-amd64-ib-sriov-cni:
12-
name: image push amd64
13-
runs-on: ubuntu-24.04
14-
steps:
15-
- name: check out the repo
16-
uses: actions/checkout@v5
17-
18-
- name: set up Docker Buildx
19-
uses: docker/setup-buildx-action@v3
20-
21-
- name: login to Docker
22-
uses: docker/login-action@v3
23-
with:
24-
registry: ghcr.io
25-
username: ${{ github.repository_owner }}
26-
password: ${{ secrets.GITHUB_TOKEN }}
27-
28-
- name: build and push ib-sriov-cni
29-
uses: docker/build-push-action@v6
30-
with:
31-
context: .
32-
push: true
33-
platforms: linux/amd64
34-
tags: |
35-
${{ env.IMAGE_NAME }}:latest-amd64
36-
file: ./Dockerfile
37-
38-
build-and-push-arm64-ib-sriov-cni:
39-
name: image push arm64
40-
runs-on: ubuntu-24.04
41-
steps:
42-
- name: check out the repo
43-
uses: actions/checkout@v5
44-
45-
- name: set up QEMU
46-
uses: docker/setup-qemu-action@v3
47-
48-
- name: set up Docker Buildx
49-
uses: docker/setup-buildx-action@v3
50-
51-
- name: login to Docker
52-
uses: docker/login-action@v3
53-
with:
54-
registry: ghcr.io
55-
username: ${{ github.repository_owner }}
56-
password: ${{ secrets.GITHUB_TOKEN }}
5711

58-
- name: build and push ib-sriov-cni
59-
uses: docker/build-push-action@v6
60-
with:
61-
context: .
62-
push: true
63-
platforms: linux/arm64
64-
tags: |
65-
${{ env.IMAGE_NAME }}:latest-arm64
66-
file: ./Dockerfile
67-
68-
build-and-push-ppc64le-ib-sriov-cni:
69-
name: image Push ppc64le
12+
jobs:
13+
build-and-push-ib-sriov-cni:
14+
name: build and push multi-arch image (Master)
7015
runs-on: ubuntu-24.04
7116
steps:
7217
- name: check out the repo
@@ -85,33 +30,13 @@ jobs:
8530
username: ${{ github.repository_owner }}
8631
password: ${{ secrets.GITHUB_TOKEN }}
8732

88-
- name: build and push ib-sriov-cni
33+
- name: build and push ib-sriov-cni (multi-arch)
8934
uses: docker/build-push-action@v6
9035
with:
9136
context: .
9237
push: true
93-
platforms: linux/ppc64le
38+
platforms: ${{ env.PLATFORMS }}
9439
tags: |
95-
${{ env.IMAGE_NAME }}:latest-ppc64le
40+
${{ env.IMAGE_NAME }}:latest
9641
file: ./Dockerfile
9742

98-
push-manifest:
99-
runs-on: ubuntu-24.04
100-
needs: [build-and-push-amd64-ib-sriov-cni,build-and-push-arm64-ib-sriov-cni,build-and-push-ppc64le-ib-sriov-cni]
101-
steps:
102-
- name: set up Docker Buildx
103-
uses: docker/setup-buildx-action@v3
104-
105-
- name: login to GitHub Container Registry
106-
uses: docker/login-action@v3
107-
with:
108-
registry: ghcr.io
109-
username: ${{ github.repository_owner }}
110-
password: ${{ secrets.GITHUB_TOKEN }}
111-
112-
- name: Create manifest for multi-arch images
113-
run: |
114-
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:latest -t ${{ env.IMAGE_NAME }}:${{ github.sha }} \
115-
${{ env.IMAGE_NAME }}:latest-amd64 \
116-
${{ env.IMAGE_NAME }}:latest-arm64 \
117-
${{ env.IMAGE_NAME }}:latest-ppc64le

.github/workflows/image-push-release.yaml

Lines changed: 7 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -2,89 +2,17 @@ name: "push images on release"
22

33
env:
44
IMAGE_NAME: ghcr.io/${{ github.repository }}
5+
PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
56

67
on:
78
push:
89
tags:
910
- v*
10-
jobs:
11-
build-and-push-amd64-ib-sriov-cni:
12-
runs-on: ubuntu-24.04
13-
name: image push AMD64
14-
steps:
15-
- name: check out the repo
16-
uses: actions/checkout@v5
17-
18-
- name: set up Docker Buildx
19-
uses: docker/setup-buildx-action@v3
20-
21-
- name: login to Docker
22-
uses: docker/login-action@v3
23-
with:
24-
registry: ghcr.io
25-
username: ${{ github.repository_owner }}
26-
password: ${{ secrets.GITHUB_TOKEN }}
27-
28-
- name: docker meta
29-
id: docker_meta
30-
uses: docker/metadata-action@v5
31-
with:
32-
images: ${{ env.IMAGE_NAME }}
33-
flavor: |
34-
latest=false
35-
tags: |
36-
type=ref,event=tag
37-
38-
- name: build and push ib-sriov-cni
39-
uses: docker/build-push-action@v6
40-
with:
41-
context: .
42-
push: true
43-
platforms: linux/amd64
44-
tags: |
45-
${{ steps.docker_meta.outputs.tags }}-amd64
46-
file: ./Dockerfile
4711

48-
build-and-push-arm64-ib-sriov-cni:
49-
runs-on: ubuntu-24.04
50-
name: image push ARM64
51-
steps:
52-
- name: check out the repo
53-
uses: actions/checkout@v5
54-
55-
- name: set up Docker Buildx
56-
uses: docker/setup-buildx-action@v3
57-
58-
- name: login to Docker
59-
uses: docker/login-action@v3
60-
with:
61-
registry: ghcr.io
62-
username: ${{ github.repository_owner }}
63-
password: ${{ secrets.GITHUB_TOKEN }}
64-
65-
- name: docker meta
66-
id: docker_meta
67-
uses: docker/metadata-action@v5
68-
with:
69-
images: ${{ env.IMAGE_NAME }}
70-
flavor: |
71-
latest=false
72-
tags: |
73-
type=ref,event=tag
74-
75-
- name: build and push ib-sriov-cni
76-
uses: docker/build-push-action@v6
77-
with:
78-
context: .
79-
push: true
80-
platforms: linux/arm64
81-
tags: |
82-
${{ steps.docker_meta.outputs.tags }}-arm64
83-
file: ./Dockerfile
84-
85-
build-and-push-ppc64le-ib-sriov-cni:
12+
jobs:
13+
build-and-push-ib-sriov-cni:
8614
runs-on: ubuntu-24.04
87-
name: image push ppc64le
15+
name: build and push multi-arch image (Release)
8816
steps:
8917
- name: check out the repo
9018
uses: actions/checkout@v5
@@ -109,43 +37,12 @@ jobs:
10937
tags: |
11038
type=ref,event=tag
11139
112-
- name: build and push ib-sriov-cni
40+
- name: build and push ib-sriov-cni (multi-arch)
11341
uses: docker/build-push-action@v6
11442
with:
11543
context: .
11644
push: true
117-
platforms: linux/arm64
45+
platforms: ${{ env.PLATFORMS }}
11846
tags: |
119-
${{ steps.docker_meta.outputs.tags }}-ppc64le
47+
${{ steps.docker_meta.outputs.tags }}
12048
file: ./Dockerfile
121-
122-
push-manifest:
123-
runs-on: ubuntu-24.04
124-
needs: [build-and-push-amd64-ib-sriov-cni,build-and-push-arm64-ib-sriov-cni,build-and-push-ppc64le-ib-sriov-cni]
125-
steps:
126-
- name: set up Docker Buildx
127-
uses: docker/setup-buildx-action@v3
128-
129-
- name: docker meta
130-
id: docker_meta
131-
uses: docker/metadata-action@v5
132-
with:
133-
images: ${{ env.IMAGE_NAME }}
134-
flavor: |
135-
latest=false
136-
tags: |
137-
type=ref,event=tag
138-
139-
- name: login to GitHub Container Registry
140-
uses: docker/login-action@v3
141-
with:
142-
registry: ghcr.io
143-
username: ${{ github.repository_owner }}
144-
password: ${{ secrets.GITHUB_TOKEN }}
145-
146-
- name: create manifest for multi-arch images
147-
run: |
148-
docker buildx imagetools create -t ${{ steps.docker_meta.outputs.tags }} \
149-
${{ steps.docker_meta.outputs.tags }}-amd64 \
150-
${{ steps.docker_meta.outputs.tags }}-arm64 \
151-
${{ steps.docker_meta.outputs.tags }}-ppc64le

Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
FROM golang:1.24-alpine as builder
1+
FROM golang:1.24-alpine AS builder
22

33
COPY . /usr/src/ib-sriov-cni
44

5-
ENV HTTP_PROXY $http_proxy
6-
ENV HTTPS_PROXY $https_proxy
5+
ARG TARGETOS
6+
ARG TARGETARCH
7+
ARG http_proxy
8+
ARG https_proxy
9+
10+
ENV HTTP_PROXY=$http_proxy \
11+
HTTPS_PROXY=$https_proxy \
12+
GOOS=$TARGETOS \
13+
GOARCH=$TARGETARCH
714

815
RUN apk add --no-cache --virtual build-dependencies build-base=~0.5
916
WORKDIR /usr/src/ib-sriov-cni

0 commit comments

Comments
 (0)