Skip to content

Commit a025747

Browse files
committed
Build linux/arm64 images on arm runner
This increases run time in GitHub Actions significantly (~45 minutes down to ~5 minutes).
1 parent 38a8167 commit a025747

File tree

2 files changed

+91
-12
lines changed

2 files changed

+91
-12
lines changed

.github/workflows/push.yml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,28 @@ jobs:
1515
- uses: actions/checkout@v6
1616
- name: Lookup PHP versions
1717
run: echo "php_versions=$(make _versions)" >> "$GITHUB_ENV"
18-
build:
19-
name: PHP
18+
build-amd64:
19+
name: PHP / amd64
2020
runs-on: ubuntu-24.04
2121
needs: php-versions
2222
strategy:
2323
fail-fast: false
2424
matrix:
2525
php: ${{ fromJSON(needs.php-versions.outputs.matrix) }}
26-
platform: [linux/arm64, linux/amd64]
2726
steps:
2827
- uses: actions/checkout@v6
2928
- name: Set up QEMU
3029
uses: docker/setup-qemu-action@v3
3130
- name: Set up Docker Buildx
3231
id: buildx
3332
uses: docker/setup-buildx-action@v3
34-
- name: Build PHP ${{ matrix.php }} (${{ matrix.platform }})
33+
- name: Build PHP ${{ matrix.php }}
3534
uses: docker/build-push-action@v6
3635
with:
3736
file: "Dockerfile"
3837
builder: ${{ steps.buildx.outputs.name }}
3938
context: .
40-
platforms: ${{ matrix.platform }}
39+
platforms: linux/amd64
4140
build-args: "php=${{ matrix.php }}"
4241
cache-from: type=gha
4342
cache-to: type=gha,mode=max
@@ -49,11 +48,48 @@ jobs:
4948
org.opencontainers.image.revision=${{ github.sha }}
5049
tags: |
5150
ghcr.io/${{ github.repository }}:${{ matrix.php }}
52-
load: ${{ (matrix.platform == 'linux/amd64') }}
51+
load: true
52+
- uses: e1himself/goss-installation-action@v1.3.0
53+
- name: Test PHP ${{ matrix.php }}
54+
run: |
55+
# Sleep a bit to ensure that PHP-FPM has time to start up.
56+
GOSS_SLEEP=15 dgoss run -e GOSS_VARS_INLINE='php_version: "${{ matrix.php }}"' ghcr.io/${{ github.repository }}:${{ matrix.php }}
57+
build-arm64:
58+
name: PHP / arm64
59+
runs-on: ubuntu-24.04-arm
60+
needs: php-versions
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
php: ${{ fromJSON(needs.php-versions.outputs.matrix) }}
65+
steps:
66+
- uses: actions/checkout@v6
67+
- name: Set up QEMU
68+
uses: docker/setup-qemu-action@v3
69+
- name: Set up Docker Buildx
70+
id: buildx
71+
uses: docker/setup-buildx-action@v3
72+
- name: Build PHP ${{ matrix.php }}
73+
uses: docker/build-push-action@v6
74+
with:
75+
file: "Dockerfile"
76+
builder: ${{ steps.buildx.outputs.name }}
77+
context: .
78+
platforms: linux/arm64
79+
build-args: "php=${{ matrix.php }}"
80+
cache-from: type=gha
81+
cache-to: type=gha,mode=max
82+
labels: |
83+
org.opencontainers.image.title=PHP ${{ matrix.php }}
84+
org.opencontainers.image.description=Docker image for PHP ${{ matrix.php }} FPM
85+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
86+
org.opencontainers.image.version=${{ matrix.php }}-${{ github.sha }}
87+
org.opencontainers.image.revision=${{ github.sha }}
88+
tags: |
89+
ghcr.io/${{ github.repository }}:${{ matrix.php }}
90+
load: true
5391
- uses: e1himself/goss-installation-action@v1.3.0
54-
if: ${{ (matrix.platform == 'linux/amd64') }}
5592
- name: Test PHP ${{ matrix.php }}
56-
if: ${{ (matrix.platform == 'linux/amd64') }}
5793
run: |
5894
# Sleep a bit to ensure that PHP-FPM has time to start up.
5995
GOSS_SLEEP=15 dgoss run -e GOSS_VARS_INLINE='php_version: "${{ matrix.php }}"' ghcr.io/${{ github.repository }}:${{ matrix.php }}

.github/workflows/release.yml

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
- uses: actions/checkout@v6
2222
- name: Lookup PHP versions
2323
run: echo "php_versions=$(make _versions)" >> "$GITHUB_ENV"
24-
build:
25-
name: PHP
24+
build-amd64:
25+
name: PHP / amd64
2626
runs-on: ubuntu-24.04
2727
needs: php-versions
2828
if: >-
@@ -51,7 +51,49 @@ jobs:
5151
builder: ${{ steps.buildx.outputs.name }}
5252
push: true
5353
context: .
54-
platforms: linux/amd64,linux/arm64
54+
platforms: linux/amd64
55+
build-args: "php=${{ matrix.php }}"
56+
cache-from: type=gha
57+
cache-to: type=gha,mode=max
58+
labels: |
59+
org.opencontainers.image.title=PHP ${{ matrix.php }}
60+
org.opencontainers.image.description=Docker image for PHP ${{ matrix.php }} FPM
61+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
62+
org.opencontainers.image.version=${{ matrix.php }}-${{ github.sha }}
63+
org.opencontainers.image.revision=${{ github.sha }}
64+
tags: |
65+
ghcr.io/${{ github.repository }}:${{ matrix.php }}
66+
build-arm64:
67+
name: PHP / arm64
68+
runs-on: ubuntu-24.04-arm
69+
needs: php-versions
70+
if: >-
71+
${{ github.event.workflow_run.conclusion == 'success' }}
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
php: ${{ fromJSON(needs.php-versions.outputs.matrix) }}
76+
steps:
77+
- uses: actions/checkout@v6
78+
- name: Set up QEMU
79+
uses: docker/setup-qemu-action@v3
80+
- name: Set up Docker Buildx
81+
id: buildx
82+
uses: docker/setup-buildx-action@v3
83+
- name: Login to GitHub Container Registry
84+
uses: docker/login-action@v3
85+
with:
86+
registry: ghcr.io
87+
username: ${{ github.actor }}
88+
password: ${{ github.token }}
89+
- name: Build PHP ${{ matrix.php }}
90+
uses: docker/build-push-action@v6
91+
with:
92+
file: "Dockerfile"
93+
builder: ${{ steps.buildx.outputs.name }}
94+
push: true
95+
context: .
96+
platforms: linux/arm64
5597
build-args: "php=${{ matrix.php }}"
5698
cache-from: type=gha
5799
cache-to: type=gha,mode=max
@@ -67,7 +109,8 @@ jobs:
67109
name: Cleanup
68110
runs-on: ubuntu-24.04
69111
needs:
70-
- build
112+
- build-amd64
113+
- build-arm64
71114
steps:
72115
- name: Delete old container packages
73116
uses: dataaxiom/ghcr-cleanup-action@v1

0 commit comments

Comments
 (0)