Skip to content

Commit e361a52

Browse files
committed
initial multiarch build support
1 parent d280e93 commit e361a52

5 files changed

Lines changed: 63 additions & 124 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build and push linux images
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version_number:
7+
required: false
8+
type: string
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
build-push-linux:
16+
runs-on: [self-hosted, linux]
17+
permissions:
18+
contents: read
19+
packages: write
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v3
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
- name: lowercase github.repository
27+
run: |
28+
echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV}
29+
- name: Docker meta
30+
uses: docker/metadata-action@v5
31+
id: meta
32+
with:
33+
images: |
34+
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
35+
tags: |
36+
# always release image under 'dev-ubuntu' tag
37+
type=raw,value=dev-ubuntu
38+
# release under 'latest-ubuntu' tag if set
39+
type=raw,value=latest-ubuntu,enable=${{ github.event.inputs.version_number != "" }}
40+
# release under version tag
41+
type=raw,value=${{ github.event.inputs.version_number }}-ubuntu,enable=${{ github.event.inputs.version_number != "" }}
42+
labels: |
43+
org.opencontainers.image.authors=Ableytner
44+
- name: Build and push
45+
uses: docker/build-push-action@v6
46+
with:
47+
context: ./linux
48+
platforms: linux/amd64,linux/arm64
49+
pull: true
50+
push: true
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/define-build-linux-image.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/release-tagged-images.yaml

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,66 +11,14 @@ defaults:
1111
shell: bash
1212

1313
jobs:
14-
build-linux:
15-
uses: ./.github/workflows/define-build-linux-image.yaml
14+
build-push-linux:
15+
uses: ./.github/workflows/build-push-linux.yaml
1616
secrets: inherit
17-
18-
tag:
19-
runs-on: self-hosted
20-
steps:
21-
- uses: mukunku/tag-exists-action@v1.6.0
22-
id: check-tag
23-
with:
24-
tag: ${{ github.event.inputs.version_number }}
25-
- name: Fail if tag exists
26-
if: steps.check-tag.outputs.exists == 'true'
27-
run: |
28-
echo "Tag ${{ github.event.inputs.version_number }} exists!"
29-
exit 1
30-
- name: Print tag if it doesn't exist
31-
if: steps.check-tag.outputs.exists == 'false'
32-
run: |
33-
echo "Tag ${{ github.event.inputs.version_number }} doesn't yet exist and can be created"
34-
35-
push-linux:
36-
needs: [tag, build-linux]
37-
runs-on: [self-hosted, linux]
38-
permissions:
39-
contents: read
40-
packages: write
41-
steps:
42-
- name: Login to GitHub Container Registry
43-
uses: docker/login-action@v3
44-
with:
45-
registry: ghcr.io
46-
username: ${{ github.repository_owner }}
47-
password: ${{ secrets.GITHUB_TOKEN }}
48-
- name: lowercase github.repository
49-
run: |
50-
echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV}
51-
- name: Download cached docker image
52-
run: |
53-
curl -X GET http://192.168.0.11:25000/attachments/gha-runner/1/image_ubuntu.tar -o /tmp/image_ubuntu.tar
54-
- name: Load image
55-
run: |
56-
docker load --input /tmp/image_ubuntu.tar
57-
- name: Push
58-
run: |
59-
docker tag ${{ env.IMAGE_NAME }}:latest-ubuntu ghcr.io/${{ env.IMAGE_NAME }}:${{ github.event.inputs.version_number }}-ubuntu
60-
docker push ghcr.io/${{ env.IMAGE_NAME }}:${{ github.event.inputs.version_number }}-ubuntu
61-
docker tag ghcr.io/${{ env.IMAGE_NAME }}:${{ github.event.inputs.version_number }}-ubuntu ghcr.io/${{ env.IMAGE_NAME }}:latest-ubuntu
62-
docker push ghcr.io/${{ env.IMAGE_NAME }}:latest-ubuntu
63-
- name: Remove local image
64-
if: always()
65-
run: |
66-
docker image rm ${{ env.IMAGE_NAME }}:latest-ubuntu
67-
- name: Remove cached docker image
68-
if: always()
69-
run: |
70-
curl -X DELETE http://192.168.0.11:25000/attachments/gha-runner/1/image_ubuntu.tar
17+
with:
18+
version_number: ${{ github.event.inputs.version_number }}
7119

7220
release:
73-
needs: [tag, build-linux, push-linux]
21+
needs: [build-push-linux]
7422
runs-on: [self-hosted, linux]
7523
permissions:
7624
contents: write

.github/workflows/run-build-images.yaml

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,6 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
build-linux:
11-
uses: ./.github/workflows/define-build-linux-image.yaml
10+
build-push-linux:
11+
uses: ./.github/workflows/build-push-linux.yaml
1212
secrets: inherit
13-
14-
push:
15-
needs: [build-linux]
16-
runs-on: [self-hosted, linux]
17-
permissions:
18-
contents: read
19-
packages: write
20-
steps:
21-
- name: Login to GitHub Container Registry
22-
uses: docker/login-action@v3
23-
with:
24-
registry: ghcr.io
25-
username: ${{ github.repository_owner }}
26-
password: ${{ secrets.GITHUB_TOKEN }}
27-
- name: lowercase github.repository
28-
run: |
29-
echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV}
30-
- name: Download cached docker image
31-
run: |
32-
curl -X GET http://192.168.0.11:25000/attachments/gha-runner/1/image_ubuntu.tar -o /tmp/image_ubuntu.tar
33-
- name: Load image
34-
run: |
35-
docker load --input /tmp/image_ubuntu.tar
36-
- name: Push
37-
run: |
38-
docker tag ${{ env.IMAGE_NAME }}:latest-ubuntu ghcr.io/${{ env.IMAGE_NAME }}:dev
39-
docker push ghcr.io/${{ env.IMAGE_NAME }}:dev
40-
- name: Remove local image
41-
if: always()
42-
run: |
43-
docker image rm ${{ env.IMAGE_NAME }}:latest-ubuntu
44-
- name: Remove cached docker image
45-
if: always()
46-
run: |
47-
curl -X DELETE http://192.168.0.11:25000/attachments/gha-runner/1/image_ubuntu.tar

linux/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
FROM ubuntu:24.04
22

3+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4+
35
# NOTE: CONTAINERD_VERSION needs to stay at 1.7.28 due to:
46
# https://github.com/nestybox/sysbox/issues/973
57
ARG RUNNER_VERSION="2.331.0" \
68
CONTAINERD_VERSION="1.7.28" \
79
DOCKER_VERSION="29.1.5" \
810
BUILDX_VERSION="0.30.1" \
911
COMPOSE_VERSION="2.40.3" \
10-
ARCH="amd64" \
11-
INSTRUCTION_SET="x64"
12+
ARCH="$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)" \
13+
INSTRUCTION_SET="$(arch | sed s/aarch64/arm64/ | sed s/x86_64/x64/)"
1214

1315
ARG DEBIAN_FRONTEND=noninteractive
1416

0 commit comments

Comments
 (0)