Skip to content

Commit 915f05d

Browse files
takaishiclaude
andauthored
feat: support native ARM64 runner for multi-arch image builds (#70)
Replace single ubuntu-latest build with matrix strategy using native ubuntu-24.04 (amd64) and ubuntu-24.04-arm (arm64) runners. Add merge job to create multi-arch manifest with imagetools create. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 924f74b commit 915f05d

1 file changed

Lines changed: 52 additions & 18 deletions

File tree

.github/workflows/wc-build-image.yml

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ on:
1212
dockerfile_path:
1313
type: string
1414
default: ./Dockerfile
15-
platforms:
16-
type: string
17-
default: linux/amd64
1815
build_args:
1916
type: string
2017
run-trivy:
@@ -30,7 +27,14 @@ on:
3027

3128
jobs:
3229
build:
33-
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
include:
33+
- runs-on: ubuntu-24.04
34+
arch: amd64
35+
- runs-on: ubuntu-24.04-arm
36+
arch: arm64
37+
runs-on: ${{ matrix.runs-on }}
3438
permissions:
3539
contents: read
3640
id-token: write
@@ -54,6 +58,38 @@ jobs:
5458
id: login-ecr
5559
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
5660

61+
- name: Build and push
62+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
63+
with:
64+
context: ./
65+
file: ${{ inputs.dockerfile_path }}
66+
builder: ${{ steps.buildx.outputs.name }}
67+
push: true
68+
tags: ${{ steps.login-ecr.outputs.registry }}/${{ inputs.image_name }}:${{ github.sha }}-${{ matrix.arch }}
69+
provenance: false
70+
cache-from: type=gha,scope=${{ matrix.arch }}
71+
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
72+
build-args: ${{ inputs.build_args }}
73+
platforms: linux/${{ matrix.arch }}
74+
75+
merge:
76+
needs: build
77+
runs-on: ubuntu-latest
78+
permissions:
79+
contents: read
80+
id-token: write
81+
timeout-minutes: 10
82+
steps:
83+
- name: Configure AWS Credentials (OIDC)
84+
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
85+
with:
86+
role-to-assume: ${{ inputs.aws_role_to_assume }}
87+
aws-region: ${{ inputs.aws_region }}
88+
89+
- name: Login to Amazon ECR
90+
id: login-ecr
91+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
92+
5793
- name: Check trigger type
5894
id: check-trigger-type
5995
shell: bash -xe {0}
@@ -91,20 +127,18 @@ jobs:
91127
prefix=branch-,type=ref,event=branch,enable=${{steps.check-trigger-type.outputs.enable_main}}
92128
prefix=release-,type=ref,event=tag,enable=${{steps.check-trigger-type.outputs.enable_release}}
93129
94-
- name: Build
95-
id: docker_build
96-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
97-
with:
98-
context: ./
99-
file: ${{ inputs.DOCKERFILE_PATH }}
100-
builder: ${{ steps.buildx.outputs.name }}
101-
push: true
102-
tags: ${{ steps.meta.outputs.tags }}
103-
labels: ${{ steps.meta.outputs.labels }}
104-
cache-from: type=gha
105-
cache-to: type=gha,mode=max
106-
build-args: ${{ inputs.build_args }}
107-
platforms: ${{ inputs.platforms }}
130+
- name: Set up Docker Buildx
131+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
132+
133+
- name: Create multi-arch manifest
134+
run: |
135+
image_base="${{ steps.login-ecr.outputs.registry }}/${{ inputs.image_name }}"
136+
for tag in ${{ steps.meta.outputs.tags }}; do
137+
docker buildx imagetools create \
138+
--tag "${tag}" \
139+
"${image_base}:${{ github.sha }}-amd64" \
140+
"${image_base}:${{ github.sha }}-arm64"
141+
done
108142
# trivyのスキャンが転けるのでコメントアウト
109143
# - name: Run Trivy vulnerability scanner
110144
# uses: aquasecurity/trivy-action@f9424c10c36e288d5fa79bd3dfd1aeb2d6eae808 # 0.33.0

0 commit comments

Comments
 (0)