Skip to content

Commit 8e5b86e

Browse files
committed
Container: Build arm64 in runner instead of QEMU, then merge and clean
1 parent fb572bf commit 8e5b86e

File tree

1 file changed

+104
-5
lines changed

1 file changed

+104
-5
lines changed

.github/workflows/container.yml

Lines changed: 104 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ env:
1515
IMAGE_NAME: ${{ github.repository }}
1616

1717
jobs:
18-
container:
18+
19+
build-amd64:
1920
name: Container
20-
runs-on: ubuntu-22.04
21+
runs-on: ubuntu-24.04${{ matrix.runner-suffix }}
22+
strategy:
23+
matrix:
24+
include:
25+
- platform: amd64
26+
runner-suffix:
2127
permissions:
2228
packages: write
2329
steps:
@@ -48,13 +54,72 @@ jobs:
4854
uses: docker/metadata-action@v5
4955
with:
5056
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
57+
flavor: suffix=--${{ matrix.platform }},latest=false
5158
labels: |
5259
org.opencontainers.image.revision=${{ steps.gitdescribe.outputs.ver }}
5360
org.opencontainers.image.licenses=GPL-2.0
5461
org.opencontainers.image.vendor=ProcessOne
5562
56-
- name: Set up QEMU
57-
uses: docker/setup-qemu-action@v3
63+
- name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v3
65+
66+
- name: Build and push Docker image
67+
uses: docker/build-push-action@v6
68+
with:
69+
build-args: |
70+
VERSION=${{ steps.gitdescribe.outputs.ver }}
71+
cache-from: type=gha
72+
cache-to: type=gha,mode=max
73+
context: .
74+
file: .github/container/Dockerfile
75+
labels: ${{ steps.meta.outputs.labels }}
76+
platforms: linux/${{ matrix.platform }}
77+
push: true
78+
tags: ${{ steps.meta.outputs.tags }}
79+
80+
build-arm64:
81+
name: Container
82+
runs-on: ubuntu-24.04${{ matrix.runner-suffix }}
83+
strategy:
84+
matrix:
85+
include:
86+
- platform: arm64
87+
runner-suffix: -arm
88+
permissions:
89+
packages: write
90+
steps:
91+
- name: Check out repository code
92+
uses: actions/checkout@v5
93+
with:
94+
fetch-depth: 0
95+
96+
- name: Checkout ejabberd-contrib
97+
uses: actions/checkout@v5
98+
with:
99+
repository: processone/ejabberd-contrib
100+
path: .ejabberd-modules/sources/ejabberd-contrib
101+
102+
- name: Log in to the Container registry
103+
uses: docker/login-action@v3
104+
with:
105+
registry: ${{ env.REGISTRY }}
106+
username: ${{ github.actor }}
107+
password: ${{ secrets.GITHUB_TOKEN }}
108+
109+
- name: Get git describe
110+
id: gitdescribe
111+
run: echo "ver=$(git describe --tags)" >> $GITHUB_OUTPUT
112+
113+
- name: Extract metadata (tags, labels) for Docker
114+
id: meta
115+
uses: docker/metadata-action@v5
116+
with:
117+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
118+
flavor: suffix=--${{ matrix.platform }},latest=false
119+
labels: |
120+
org.opencontainers.image.revision=${{ steps.gitdescribe.outputs.ver }}
121+
org.opencontainers.image.licenses=GPL-2.0
122+
org.opencontainers.image.vendor=ProcessOne
58123
59124
- name: Set up Docker Buildx
60125
uses: docker/setup-buildx-action@v3
@@ -69,6 +134,40 @@ jobs:
69134
context: .
70135
file: .github/container/Dockerfile
71136
labels: ${{ steps.meta.outputs.labels }}
72-
platforms: linux/amd64,linux/arm64
137+
platforms: linux/${{ matrix.platform }}
73138
push: true
74139
tags: ${{ steps.meta.outputs.tags }}
140+
141+
merge:
142+
needs:
143+
- build-amd64
144+
- build-arm64
145+
runs-on: ubuntu-24.04
146+
outputs:
147+
image-uri: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.merge.outputs.digest }}
148+
steps:
149+
- uses: docker/login-action@v3
150+
with:
151+
registry: ghcr.io
152+
username: ${{ github.actor }}
153+
password: ${{ secrets.GITHUB_TOKEN }}
154+
- uses: docker/metadata-action@v5
155+
id: metadata
156+
with:
157+
images: ghcr.io/${{ github.repository }}
158+
- uses: int128/docker-manifest-create-action@v2
159+
id: merge
160+
with:
161+
index-annotations: ${{ steps.metadata.outputs.labels }}
162+
tags: ${{ steps.metadata.outputs.tags }}
163+
sources: |
164+
${{ steps.metadata.outputs.tags }}--amd64
165+
${{ steps.metadata.outputs.tags }}--arm64
166+
- uses: dataaxiom/ghcr-cleanup-action@v1
167+
with:
168+
dry-run: true
169+
delete-tags: '*--a??64'
170+
delete-untagged: true
171+
delete-ghost-images: true
172+
delete-partial-images: true
173+
delete-orphaned-images: true

0 commit comments

Comments
 (0)