From fbe4ba571fb638bbc2b8dbe36afaa930926fc3a9 Mon Sep 17 00:00:00 2001 From: Jiri Peinlich Date: Wed, 4 Jan 2023 02:22:48 +0000 Subject: [PATCH] Allow -Pdocker-platform during distDocker (#4828) As an example of usecase - this should make it easier to build linux/amd64 images on M1. Signed-off-by: Jiri Peinlich Signed-off-by: Jiri Peinlich Co-authored-by: Sally MacFarlane --- build.gradle | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b3c580c19c..a8f80bc74e 100644 --- a/build.gradle +++ b/build.gradle @@ -649,9 +649,14 @@ task distDocker { } exec { def image = "${dockerImageName}:${dockerBuildVersion}-${jvmVariant}" + def dockerPlatform = "" + if (project.hasProperty('docker-platform')){ + dockerPlatform = "--platform ${project.getProperty('docker-platform')}" + println "Building for platform ${project.getProperty('docker-platform')}" + } executable "sh" workingDir dockerBuildDir - args "-c", "docker build --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ." + args "-c", "docker build ${dockerPlatform} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ." } }