Skip to content

Commit 61f3188

Browse files
authored
Merge pull request #75 from TrafeX/multi-arch-builds
Add multi-arch Docker builds
2 parents 70b353a + 1bf1f81 commit 61f3188

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

.github/workflows/deploy.yaml renamed to .github/workflows/build.yaml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,26 @@ on:
88

99
env:
1010
IMAGE_NAME: trafex/php-nginx
11+
IMAGE_TAG: ${{ github.sha }}
1112

1213
jobs:
13-
deploy:
14+
build:
1415
runs-on: ubuntu-latest
1516

1617
steps:
1718
- name: Checkout
1819
uses: actions/checkout@v2
1920

21+
- name: Set up QEMU
22+
uses: docker/setup-qemu-action@v1
23+
24+
- name: Set up Docker Buildx
25+
id: buildx
26+
uses: docker/setup-buildx-action@v1
27+
2028
- name: Build image
2129
run: |-
22-
docker build -t $IMAGE_NAME .
23-
docker tag $IMAGE_NAME:latest $IMAGE_NAME:${{ github.sha }}
30+
docker build -t $IMAGE_NAME:$IMAGE_TAG .
2431
2532
- name: Smoke test image
2633
run: |-
@@ -47,17 +54,26 @@ jobs:
4754
username: ${{ secrets.DOCKERHUB_USERNAME }}
4855
password: ${{ secrets.DOCKERHUB_TOKEN }}
4956

50-
- name: Push latest image
57+
- name: Build multi-arch image and push latest tag
5158
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
5259
run: |-
53-
docker push $IMAGE_NAME:latest
60+
docker buildx build \
61+
--cache-from=$IMAGE_NAME:latest
62+
--push \
63+
-t $IMAGE_NAME:latest \
64+
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
65+
.
5466
5567
- name: Set tag in environment
5668
if: contains(github.ref, 'refs/tags/')
5769
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
5870

59-
- name: Push tagged image
71+
- name: Build multi-arch image and push release tag
6072
if: contains(github.ref, 'refs/tags/')
6173
run: |-
62-
docker tag $IMAGE_NAME:${{ github.sha }} $IMAGE_NAME:$RELEASE_VERSION
63-
docker push $IMAGE_NAME:$RELEASE_VERSION
74+
docker buildx build \
75+
--cache-from=$IMAGE_NAME:latest
76+
--push \
77+
-t $IMAGE_NAME:$RELEASE_VERSION \
78+
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
79+
.

docker-compose.test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: '3.5'
22
services:
33
app:
4+
image: ${IMAGE_NAME}:${IMAGE_TAG}
45
build: .
56
sut:
67
image: alpine:3.13

0 commit comments

Comments
 (0)