Skip to content

Commit e10c297

Browse files
committed
Update docker workflow to build multiarch image. (#3350)
1 parent 46ea490 commit e10c297

File tree

1 file changed

+59
-5
lines changed

1 file changed

+59
-5
lines changed

.github/workflows/publish_docker_images.yml

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,19 @@ on:
99
- happy-plazza
1010
- qw*
1111
- v*
12+
env:
13+
REGISTRY_IMAGE: quickwit/quickwit
1214

1315
jobs:
1416
docker:
15-
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
include:
20+
- os: ubuntu-latest
21+
platform: linux/amd64
22+
- os: buildjet-4vcpu-ubuntu-2204-arm
23+
platform: linux/arm64
24+
runs-on: ${{ matrix.os }}
1625
steps:
1726
- name: Checkout
1827
uses: actions/checkout@v3
@@ -28,7 +37,7 @@ jobs:
2837
uses: docker/metadata-action@v4
2938
with:
3039
images: |
31-
quickwit/quickwit
40+
${{ env.REGISTRY_IMAGE }}
3241
tags: |
3342
type=edge,branch=main
3443
type=edge,branch=main,suffix=-bullseye
@@ -53,14 +62,59 @@ jobs:
5362
echo "QW_COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
5463
echo "QW_COMMIT_TAGS=$(git tag --points-at HEAD | tr '\n' ',')" >> $GITHUB_ENV
5564
56-
- name: Build and push
65+
- name: Build and push image
5766
uses: docker/build-push-action@v4
67+
id: build
5868
with:
5969
context: .
60-
push: true
70+
platforms: ${{ matrix.platform }}
6171
build-args: |
6272
QW_COMMIT_DATE=${{ env.QW_COMMIT_DATE }}
6373
QW_COMMIT_HASH=${{ env.QW_COMMIT_HASH }}
6474
QW_COMMIT_TAGS=${{ env.QW_COMMIT_TAGS }}
65-
tags: ${{ steps.meta.outputs.tags }}
6675
labels: ${{ steps.meta.outputs.labels }}
76+
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
77+
78+
- name: Export digest
79+
run: |
80+
mkdir -p /tmp/digests
81+
digest="${{ steps.build.outputs.digest }}"
82+
touch "/tmp/digests/${digest#sha256:}"
83+
84+
- name: Upload digest
85+
uses: actions/upload-artifact@v3
86+
with:
87+
name: digests
88+
path: /tmp/digests/*
89+
if-no-files-found: error
90+
retention-days: 1
91+
92+
merge:
93+
runs-on: ubuntu-latest
94+
needs: [docker]
95+
steps:
96+
- name: Download digests
97+
uses: actions/download-artifact@v3
98+
with:
99+
name: digests
100+
path: /tmp/digests
101+
- name: Set up Docker Buildx
102+
uses: docker/setup-buildx-action@v2
103+
- name: Docker meta
104+
id: meta
105+
uses: docker/metadata-action@v4
106+
with:
107+
images: ${{ env.REGISTRY_IMAGE }}
108+
- name: Login to Docker Hub
109+
uses: docker/login-action@v2
110+
with:
111+
username: ${{ secrets.DOCKERHUB_USERNAME }}
112+
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
113+
- name: Create manifest list and push tags
114+
working-directory: /tmp/digests
115+
run: |
116+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
117+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
118+
- name: Inspect image
119+
run: |
120+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)