88 IMAGE_NAME : ${{ github.repository }}
99
1010jobs :
11- build-and-push :
12- runs-on : ubuntu-latest
11+ build :
12+ timeout-minutes : 30
13+ strategy :
14+ fail-fast : false
15+ matrix :
16+ include :
17+ - platform : linux/amd64
18+ runner : ubuntu-latest
19+ - platform : linux/arm64
20+ runner : ubuntu-24.04-arm
21+ runs-on : ${{ matrix.runner }}
1322 permissions :
1423 contents : read
1524 packages : write
25+ outputs :
26+ digest-amd64 : ${{ steps.build.outputs.digest }}
27+ digest-arm64 : ${{ steps.build.outputs.digest }}
1628
1729 steps :
1830 - name : Checkout repository
3345 - name : Build frontend
3446 run : bun run --cwd frontend build
3547
36- - name : Set up QEMU
37- uses : docker/setup-qemu-action@v3
38-
3948 - name : Set up Docker Buildx
4049 uses : docker/setup-buildx-action@v3
4150
@@ -46,26 +55,72 @@ jobs:
4655 username : ${{ github.actor }}
4756 password : ${{ secrets.GITHUB_TOKEN }}
4857
58+ - name : Extract platform suffix
59+ id : platform
60+ run : |
61+ platform="${{ matrix.platform }}"
62+ echo "suffix=${platform#linux/}" >> $GITHUB_OUTPUT
63+
4964 - name : Extract Docker metadata
5065 id : meta
5166 uses : docker/metadata-action@v5
5267 with :
5368 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5469 tags : |
55- type=raw,value=${{ steps.sha.outputs.short }}
56- type=raw,value=latest
70+ type=raw,value=${{ steps.sha.outputs.short }}-${{ steps.platform.outputs.suffix }}
5771
5872 - name : Build and push Docker image
73+ id : build
5974 uses : docker/build-push-action@v6
6075 with :
6176 context : .
6277 file : ./Dockerfile
6378 target : production
6479 push : true
65- platforms : linux/amd64,linux/arm64
80+ platforms : ${{ matrix.platform }}
6681 tags : ${{ steps.meta.outputs.tags }}
6782 labels : ${{ steps.meta.outputs.labels }}
68- cache-from : type=gha
69- cache-to : type=gha,mode=max
83+ cache-from : type=gha,scope=${{ matrix.platform }}
84+ cache-to : type=gha,mode=max,scope=${{ matrix.platform }}
7085 build-args : |
7186 PYTHON_VERSION=3.12
87+
88+ manifest :
89+ timeout-minutes : 10
90+ needs : build
91+ runs-on : ubuntu-latest
92+ permissions :
93+ contents : read
94+ packages : write
95+
96+ steps :
97+ - name : Checkout repository
98+ uses : actions/checkout@v4
99+
100+ - name : Get short commit SHA
101+ id : sha
102+ run : echo "short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
103+
104+ - name : Log in to Container Registry
105+ uses : docker/login-action@v3
106+ with :
107+ registry : ${{ env.REGISTRY }}
108+ username : ${{ github.actor }}
109+ password : ${{ secrets.GITHUB_TOKEN }}
110+
111+ - name : Create and push manifest
112+ run : |
113+ IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
114+ SHA="${{ steps.sha.outputs.short }}"
115+
116+ # Create manifest for commit SHA tag
117+ docker manifest create ${IMAGE}:${SHA} \
118+ --amend ${IMAGE}:${SHA}-amd64 \
119+ --amend ${IMAGE}:${SHA}-arm64
120+ docker manifest push ${IMAGE}:${SHA}
121+
122+ # Create manifest for latest tag
123+ docker manifest create ${IMAGE}:latest \
124+ --amend ${IMAGE}:${SHA}-amd64 \
125+ --amend ${IMAGE}:${SHA}-arm64
126+ docker manifest push ${IMAGE}:latest
0 commit comments