13
13
types : [published]
14
14
15
15
jobs :
16
- docker-hub :
17
- runs-on : ubuntu-latest
16
+ build-amd64 :
17
+ runs-on : ubuntu-24.04
18
18
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
+
29
+ - uses : actions/checkout@v4
30
+ with :
31
+ token : ${{ secrets.botGitHubToken }}
32
+
33
+ - name : Load .env file
34
+ uses : cardinalby/export-env-action@v2
35
+ with :
36
+ envFile : .env
37
+
38
+ - name : Set up Docker Buildx
39
+ uses : docker/setup-buildx-action@v3
40
+
41
+ - name : Login to DockerHub
42
+ uses : docker/login-action@v3
43
+ with :
44
+
45
+ password : ${{ secrets.botDockerHubPassword }}
46
+
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)
53
+ if : github.ref == 'refs/heads/main'
54
+ uses : docker/build-push-action@v6
55
+ with :
56
+ platforms : linux/amd64
57
+ context : .
58
+ push : true
59
+ build-args : |
60
+ SERVICE_NAME=${{ env.SERVICE_NAME }}
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
65
+
66
+ - name : Set Versions
67
+ if : github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
68
+ uses : actions/github-script@v6
69
+ id : set_version
70
+ with :
71
+ script : |
72
+ const tag = '${{ github.ref_name }}'
73
+ const no_v_tag = tag.replace('v', '')
74
+ core.setOutput('tag', tag)
75
+ core.setOutput('no_v_tag', no_v_tag)
76
+
77
+ - name : Build and push amd64 (rc/release)
78
+ if : startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
79
+ uses : docker/build-push-action@v6
80
+ with :
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
+
19
104
- uses : actions/checkout@v4
20
105
with :
21
106
token : ${{ secrets.botGitHubToken }}
@@ -34,19 +119,24 @@ jobs:
34
119
35
120
password : ${{ secrets.botDockerHubPassword }}
36
121
37
- - name : Build and push (latest)
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)
38
128
if : github.ref == 'refs/heads/main'
39
129
uses : docker/build-push-action@v6
40
130
with :
41
- platforms : linux/amd64,linux/ arm64
131
+ platforms : linux/arm64
42
132
context : .
43
133
push : true
44
134
build-args : |
45
135
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
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
50
140
51
141
- name : Set Versions
52
142
if : github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
@@ -59,16 +149,51 @@ jobs:
59
149
core.setOutput('tag', tag)
60
150
core.setOutput('no_v_tag', no_v_tag)
61
151
62
- - name : Build and push (rc/release)
152
+ - name : Build and push arm64 (rc/release)
63
153
if : startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
64
154
uses : docker/build-push-action@v6
65
155
with :
66
- platforms : linux/amd64,linux/ arm64
156
+ platforms : linux/arm64
67
157
context : .
68
158
push : true
69
159
build-args : |
70
160
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
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
+ - name : Login to DockerHub
171
+ uses : docker/login-action@v3
172
+ with :
173
+
174
+ password : ${{ secrets.botDockerHubPassword }}
175
+
176
+ - name : Create and push multi-arch manifest (latest)
177
+ if : github.ref == 'refs/heads/main'
178
+ run : |
179
+ docker buildx imagetools create -t instill/${{ env.SERVICE_NAME }}:latest \
180
+ instill/${{ env.SERVICE_NAME }}:latest-amd64 \
181
+ instill/${{ env.SERVICE_NAME }}:latest-arm64
182
+
183
+ - name : Set Versions
184
+ if : startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
185
+ uses : actions/github-script@v6
186
+ id : set_version
187
+ with :
188
+ script : |
189
+ const tag = '${{ github.ref_name }}'
190
+ const no_v_tag = tag.replace('v', '')
191
+ core.setOutput('tag', tag)
192
+ core.setOutput('no_v_tag', no_v_tag)
193
+
194
+ - name : Create and push multi-arch manifest (rc/release)
195
+ if : startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
196
+ run : |
197
+ docker buildx imagetools create -t instill/${{ env.SERVICE_NAME }}:${{ steps.set_version.outputs.no_v_tag }} \
198
+ instill/${{ env.SERVICE_NAME }}:${{ steps.set_version.outputs.no_v_tag }}-amd64 \
199
+ instill/${{ env.SERVICE_NAME }}:${{ steps.set_version.outputs.no_v_tag }}-arm64
0 commit comments