@@ -80,6 +80,9 @@ task sourceDocker {
8080
8181 if (targetingPlatform. contains(" aarch64" ) || targetingPlatform. contains(" arm64" )) {
8282 dockerfileName = " ${ dockerfileName} .arm64"
83+ image = " ${ image} -arm64"
84+ } else {
85+ image = " ${ image} -amd64"
8386 }
8487
8588 doLast {
@@ -100,7 +103,11 @@ task sourceDocker {
100103 def gitDetails = getGitCommitDetails(7 )
101104 executable shell
102105 workingDir dockerBuildDir
103- args " -c" , " docker build --no-cache ${ dockerPlatform} --build-arg BUILD_DATE=${ buildTime()} --build-arg VERSION=${ dockerBuildVersion} --build-arg VCS_REF=${ gitDetails.hash} -t ${ image} ."
106+ /* if (targetingPlatform.contains("aarch64") || targetingPlatform.contains("arm64")) {
107+ environment 'DOCKER_BUILDKIT', '0'
108+ } */
109+ // Add `--provenance=false --sbom=false` to fix unknown dirty manifests: https://github.com/orgs/community/discussions/45969
110+ args " -c" , " docker build --provenance=false --sbom=false --no-cache ${ dockerPlatform} --build-arg BUILD_DATE=${ buildTime()} --build-arg VERSION=${ dockerBuildVersion} --build-arg VCS_REF=${ gitDetails.hash} -t ${ image} ."
104111 }
105112 }
106113}
@@ -158,6 +165,11 @@ tasks.register("downloadGossBinaries") {
158165task testDocker {
159166 def dockerReportsDir = " ${ rootDir} /../docker/reports/"
160167 def image = " ${ dockerImageName} :${ dockerBuildVersion} "
168+ if (targetingPlatform. contains(" aarch64" ) || targetingPlatform. contains(" arm64" )) {
169+ image = " ${ image} -arm64"
170+ } else {
171+ image = " ${ image} -amd64"
172+ }
161173 imageArch = [" sh" , " -c" , " docker inspect ${ image} --format='{{.Architecture}}'" ]
162174 .execute()
163175 .text
@@ -183,15 +195,75 @@ task testDocker {
183195// Make sure to `docker login` first
184196task dockerUpload {
185197 def image = " ${ dockerImageName} :${ dockerBuildVersion} "
198+ def archs = [
199+ " arm64" ,
200+ " amd64" ]
186201
187202 doLast {
188- exec {
189- def cmd = " docker push '${ image} '"
190- println " Executing '${ cmd} '"
191- executable shell
192- args " -c" , cmd
203+ archs. forEach { arch ->
204+ println " Uploading for ${ image} -${ arch} ..."
205+ exec {
206+ def cmd = " docker push '${ image} -${ arch} '"
207+ println " Executing '${ cmd} '"
208+ executable shell
209+ args " -c" , cmd
210+ }
193211 }
212+
213+ }
214+ }
215+
216+ task manifestDocker {
217+ def image = " ${ dockerImageName} :${ dockerBuildVersion} "
218+ def archs = [
219+ " arm64" ,
220+ " amd64" ] // TODO: this assumes dockerUpload task has already been run on 2 different archs!
221+ doLast {
222+ exec {
223+ def targets = " "
224+ archs. forEach { arch -> targets + = " '${ image} -${ arch} ' " }
225+ def cmd = " docker manifest create '${ image} ' ${ targets} "
226+ println " Executing '${ cmd} '"
227+ executable shell
228+ args " -c" , cmd
229+ }
230+ exec {
231+ def cmd = " docker manifest push '${ image} '"
232+ println " Executing '${ cmd} '"
233+ executable shell
234+ args " -c" , cmd
235+ }
236+ }
237+ }
238+
239+ task manifestDockerAsLatest {
240+ def image = " ${ dockerImageName} :${ dockerBuildVersion} "
241+ def targetImage = " ${ dockerImageName} :latest"
242+ def archs = [
243+ " arm64" ,
244+ " amd64" ] // TODO: this assumes dockerUpload task has already been run on 2 different archs!
245+ doLast {
246+ exec {
247+ def cmd = " docker manifest rm '${ targetImage} ' "
248+ println " Executing '${ cmd} '"
249+ executable shell
250+ args " -c" , cmd
251+ }
252+ exec {
253+ def targets = " "
254+ archs. forEach { arch -> targets + = " '${ image} -${ arch} ' " }
255+ def cmd = " docker manifest create '${ targetImage} ' ${ targets} "
256+ println " Executing '${ cmd} '"
257+ executable shell
258+ args " -c" , cmd
194259 }
260+ exec {
261+ def cmd = " docker manifest push '${ targetImage} '"
262+ println " Executing '${ cmd} '"
263+ executable shell
264+ args " -c" , cmd
265+ }
266+ }
195267}
196268
197269tasks. named(' jar' ) {
0 commit comments