1313 types : [published]
1414
1515jobs :
16- docker-hub :
17- runs-on : ubuntu-latest
16+ build-amd64 :
17+ runs-on : ubuntu-24.04
1818 steps :
19+ - name : Maximize build space
20+ uses : easimon/maximize-build-space@master
21+ with :
22+ overprovision-lvm : " true"
23+ remove-dotnet : " true"
24+ build-mount-path : " /var/lib/docker/"
25+
26+ - name : Restart docker
27+ run : sudo service docker restart
28+
1929 - uses : actions/checkout@v4
2030 with :
2131 token : ${{ secrets.botGitHubToken }}
@@ -34,19 +44,24 @@ jobs:
3444 username : drop@instill-ai.com
3545 password : ${{ secrets.botDockerHubPassword }}
3646
37- - name : Build and push (latest)
47+ - name : Set short commit SHA
48+ if : github.ref == 'refs/heads/main'
49+ run : |
50+ echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
51+
52+ - name : Build and push amd64 (latest)
3853 if : github.ref == 'refs/heads/main'
3954 uses : docker/build-push-action@v6
4055 with :
41- platforms : linux/amd64,linux/arm64
56+ platforms : linux/amd64
4257 context : .
4358 push : true
4459 build-args : |
4560 SERVICE_NAME=${{ env.SERVICE_NAME }}
46- SERVICE_VERSION=${{ github.sha }}
47- tags : instill/artifact-backend :latest
48- cache-from : type=registry,ref=instill/artifact-backend :buildcache
49- cache-to : type=registry,ref=instill/artifact-backend :buildcache,mode=max
61+ SERVICE_VERSION=${{ env.COMMIT_SHORT_SHA }}
62+ tags : instill/${{ env.SERVICE_NAME }} :latest-amd64
63+ cache-from : type=registry,ref=instill/${{ env.SERVICE_NAME }} :buildcache
64+ cache-to : type=registry,ref=instill/${{ env.SERVICE_NAME }} :buildcache,mode=max
5065
5166 - name : Set Versions
5267 if : github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
@@ -59,16 +74,135 @@ jobs:
5974 core.setOutput('tag', tag)
6075 core.setOutput('no_v_tag', no_v_tag)
6176
62- - name : Build and push (rc/release)
77+ - name : Build and push amd64 (rc/release)
6378 if : startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
6479 uses : docker/build-push-action@v6
6580 with :
66- platforms : linux/amd64,linux/arm64
81+ platforms : linux/amd64
82+ context : .
83+ push : true
84+ build-args : |
85+ SERVICE_NAME=${{ env.SERVICE_NAME }}
86+ SERVICE_VERSION=${{ steps.set_version.outputs.no_v_tag }}
87+ tags : instill/${{ env.SERVICE_NAME }}:${{ steps.set_version.outputs.no_v_tag }}-amd64
88+ cache-from : type=registry,ref=instill/${{ env.SERVICE_NAME }}:buildcache
89+ cache-to : type=registry,ref=instill/${{ env.SERVICE_NAME }}:buildcache,mode=max
90+
91+ build-arm64 :
92+ runs-on : ubuntu-24.04-arm
93+ steps :
94+ - name : Maximize build space
95+ uses : easimon/maximize-build-space@master
96+ with :
97+ overprovision-lvm : " true"
98+ remove-dotnet : " true"
99+ build-mount-path : " /var/lib/docker/"
100+
101+ - name : Restart docker
102+ run : sudo service docker restart
103+
104+ - uses : actions/checkout@v4
105+ with :
106+ token : ${{ secrets.botGitHubToken }}
107+
108+ - name : Load .env file
109+ uses : cardinalby/export-env-action@v2
110+ with :
111+ envFile : .env
112+
113+ - name : Set up Docker Buildx
114+ uses : docker/setup-buildx-action@v3
115+
116+ - name : Login to DockerHub
117+ uses : docker/login-action@v3
118+ with :
119+ username : drop@instill-ai.com
120+ password : ${{ secrets.botDockerHubPassword }}
121+
122+ - name : Set short commit SHA
123+ if : github.ref == 'refs/heads/main'
124+ run : |
125+ echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
126+
127+ - name : Build and push arm64 (latest)
128+ if : github.ref == 'refs/heads/main'
129+ uses : docker/build-push-action@v6
130+ with :
131+ platforms : linux/arm64
67132 context : .
68133 push : true
69134 build-args : |
70135 SERVICE_NAME=${{ env.SERVICE_NAME }}
71- SERVICE_VERSION=${{steps.set_version.outputs.no_v_tag}}
72- tags : instill/artifact-backend:${{steps.set_version.outputs.no_v_tag}}
73- cache-from : type=registry,ref=instill/artifact-backend:buildcache
74- cache-to : type=registry,ref=instill/artifact-backend:buildcache,mode=max
136+ SERVICE_VERSION=${{ env.COMMIT_SHORT_SHA }}
137+ tags : instill/${{ env.SERVICE_NAME }}:latest-arm64
138+ cache-from : type=registry,ref=instill/${{ env.SERVICE_NAME }}:buildcache
139+ cache-to : type=registry,ref=instill/${{ env.SERVICE_NAME }}:buildcache,mode=max
140+
141+ - name : Set Versions
142+ if : github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
143+ uses : actions/github-script@v6
144+ id : set_version
145+ with :
146+ script : |
147+ const tag = '${{ github.ref_name }}'
148+ const no_v_tag = tag.replace('v', '')
149+ core.setOutput('tag', tag)
150+ core.setOutput('no_v_tag', no_v_tag)
151+
152+ - name : Build and push arm64 (rc/release)
153+ if : startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
154+ uses : docker/build-push-action@v6
155+ with :
156+ platforms : linux/arm64
157+ context : .
158+ push : true
159+ build-args : |
160+ SERVICE_NAME=${{ env.SERVICE_NAME }}
161+ SERVICE_VERSION=${{ steps.set_version.outputs.no_v_tag }}
162+ tags : instill/${{ env.SERVICE_NAME }}:${{ steps.set_version.outputs.no_v_tag }}-arm64
163+ cache-from : type=registry,ref=instill/${{ env.SERVICE_NAME }}:buildcache
164+ cache-to : type=registry,ref=instill/${{ env.SERVICE_NAME }}:buildcache,mode=max
165+
166+ combine-and-push :
167+ needs : [build-amd64, build-arm64]
168+ runs-on : ubuntu-24.04
169+ steps :
170+ - uses : actions/checkout@v4
171+ with :
172+ token : ${{ secrets.botGitHubToken }}
173+
174+ - name : Load .env file
175+ uses : cardinalby/export-env-action@v2
176+ with :
177+ envFile : .env
178+
179+ - name : Login to DockerHub
180+ uses : docker/login-action@v3
181+ with :
182+ username : drop@instill-ai.com
183+ password : ${{ secrets.botDockerHubPassword }}
184+
185+ - name : Create and push multi-arch manifest (latest)
186+ if : github.ref == 'refs/heads/main'
187+ run : |
188+ docker buildx imagetools create -t instill/${{ env.SERVICE_NAME }}:latest \
189+ instill/${{ env.SERVICE_NAME }}:latest-amd64 \
190+ instill/${{ env.SERVICE_NAME }}:latest-arm64
191+
192+ - name : Set Versions
193+ if : startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
194+ uses : actions/github-script@v6
195+ id : set_version
196+ with :
197+ script : |
198+ const tag = '${{ github.ref_name }}'
199+ const no_v_tag = tag.replace('v', '')
200+ core.setOutput('tag', tag)
201+ core.setOutput('no_v_tag', no_v_tag)
202+
203+ - name : Create and push multi-arch manifest (rc/release)
204+ if : startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
205+ run : |
206+ docker buildx imagetools create -t instill/${{ env.SERVICE_NAME }}:${{ steps.set_version.outputs.no_v_tag }} \
207+ instill/${{ env.SERVICE_NAME }}:${{ steps.set_version.outputs.no_v_tag }}-amd64 \
208+ instill/${{ env.SERVICE_NAME }}:${{ steps.set_version.outputs.no_v_tag }}-arm64
0 commit comments