Skip to content

Commit

Permalink
Allow -Pdocker-platform during distDocker (hyperledger#4828)
Browse files Browse the repository at this point in the history
As an example of usecase - this should make it easier to build linux/amd64 images on M1.

Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>

Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
  • Loading branch information
2 people authored and siladu committed Jan 15, 2023
1 parent fbf0e21 commit 9b3f70a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -639,16 +639,21 @@ task distDocker {
def dockerBuildDir = "build/docker-besu/"

doLast {
for (def variant in dockerVariants) {
for (def jvmVariant in dockerVariants) {
copy {
from file("${projectDir}/docker/${variant}/Dockerfile")
from file("${projectDir}/docker/${jvmVariant}/Dockerfile")
into(dockerBuildDir)
}
exec {
def image = "${dockerImageName}:${dockerBuildVersion}-${variant}"
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} ."
}
}
// tag the "default" (which is the variant in the zero position)
Expand Down

0 comments on commit 9b3f70a

Please sign in to comment.