|
|
@ -605,7 +605,9 @@ artifactoryPublish { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}" |
|
|
|
def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}" |
|
|
|
def dockerImageName = project.hasProperty("dockerImageName") ? project.getProperty("dockerImageName") : "hyperledger/besu" |
|
|
|
def dockerOrgName = project.hasProperty('dockerOrgName') ? project.getProperty("dockerOrgName") : "hyperledger" |
|
|
|
|
|
|
|
def dockerArtifactName = project.hasProperty("dockerArtifactName") ? project.getProperty("dockerArtifactName") : "besu" |
|
|
|
|
|
|
|
def dockerImageName = "${dockerOrgName}/${dockerArtifactName}" |
|
|
|
def dockerVariants = project.hasProperty("dockerVariants") ? project.getProperty("dockerVariants").split(",") : [ |
|
|
|
def dockerVariants = project.hasProperty("dockerVariants") ? project.getProperty("dockerVariants").split(",") : [ |
|
|
|
"openjdk-11", |
|
|
|
"openjdk-11", |
|
|
|
"openjdk-11-debug", |
|
|
|
"openjdk-11-debug", |
|
|
@ -639,18 +641,25 @@ task distDocker { |
|
|
|
def dockerBuildDir = "build/docker-besu/" |
|
|
|
def dockerBuildDir = "build/docker-besu/" |
|
|
|
|
|
|
|
|
|
|
|
doLast { |
|
|
|
doLast { |
|
|
|
for (def variant in dockerVariants) { |
|
|
|
for (def jvmVariant in dockerVariants) { |
|
|
|
copy { |
|
|
|
copy { |
|
|
|
from file("${projectDir}/docker/${variant}/Dockerfile") |
|
|
|
from file("${projectDir}/docker/${jvmVariant}/Dockerfile") |
|
|
|
into(dockerBuildDir) |
|
|
|
into(dockerBuildDir) |
|
|
|
} |
|
|
|
} |
|
|
|
exec { |
|
|
|
exec { |
|
|
|
def image = "${dockerImageName}:${dockerBuildVersion}-${variant}" |
|
|
|
def image = "${dockerImageName}:${dockerBuildVersion}-${jvmVariant}" |
|
|
|
executable "sh" |
|
|
|
executable "sh" |
|
|
|
workingDir dockerBuildDir |
|
|
|
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 --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ." |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def shaTag = "gitSha-${getCheckedOutGitCommitHash(40)}" //full length sha |
|
|
|
|
|
|
|
exec { |
|
|
|
|
|
|
|
executable "sh" |
|
|
|
|
|
|
|
args "-c", "docker tag '${dockerImageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${dockerImageName}:${shaTag}'" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// tag the "default" (which is the variant in the zero position) |
|
|
|
// tag the "default" (which is the variant in the zero position) |
|
|
|
exec { |
|
|
|
exec { |
|
|
|
executable "sh" |
|
|
|
executable "sh" |
|
|
@ -730,10 +739,9 @@ task dockerUpload { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def isInterimBuild = (dockerBuildVersion ==~ /.*-SNAPSHOT/) || (dockerBuildVersion ==~ /.*-alpha/) |
|
|
|
def isInterimBuild = (dockerBuildVersion ==~ /.*-SNAPSHOT/) || (dockerBuildVersion ==~ /.*-alpha/) |
|
|
|
|| (dockerBuildVersion ==~ /.*-beta/) || (dockerBuildVersion ==~ /.*-RC/) |
|
|
|
|| (dockerBuildVersion ==~ /.*-beta/) || (dockerBuildVersion ==~ /.*-RC.*/) |
|
|
|
|
|
|
|
|
|
|
|
if (!isInterimBuild) { |
|
|
|
if (!isInterimBuild) { |
|
|
|
additionalTags.add('latest') |
|
|
|
|
|
|
|
additionalTags.add(dockerBuildVersion.split(/\./)[0..1].join('.')) |
|
|
|
additionalTags.add(dockerBuildVersion.split(/\./)[0..1].join('.')) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -760,6 +768,7 @@ task dockerUpload { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
task manifestDocker { |
|
|
|
task manifestDocker { |
|
|
|
|
|
|
|
dependsOn distDocker |
|
|
|
|
|
|
|
|
|
|
|
def image = "${dockerImageName}:${dockerBuildVersion}" |
|
|
|
def image = "${dockerImageName}:${dockerBuildVersion}" |
|
|
|
def archs = ["arm64", "amd64"] |
|
|
|
def archs = ["arm64", "amd64"] |
|
|
@ -770,7 +779,6 @@ task manifestDocker { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!(dockerBuildVersion ==~ /.*-SNAPSHOT/)) { |
|
|
|
if (!(dockerBuildVersion ==~ /.*-SNAPSHOT/)) { |
|
|
|
tags.add("${dockerImageName}:latest") |
|
|
|
|
|
|
|
tags.add("${dockerImageName}:" + dockerBuildVersion.split(/\./)[0..1].join('.')) |
|
|
|
tags.add("${dockerImageName}:" + dockerBuildVersion.split(/\./)[0..1].join('.')) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -865,15 +873,16 @@ def calculateVersion() { |
|
|
|
return version |
|
|
|
return version |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def getCheckedOutGitCommitHash() { |
|
|
|
|
|
|
|
|
|
|
|
def getCheckedOutGitCommitHash(length = 8) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
def gitFolder = "$projectDir/.git/" |
|
|
|
def gitFolder = "$projectDir/.git/" |
|
|
|
if (!file(gitFolder).isDirectory()) { |
|
|
|
if (!file(gitFolder).isDirectory()) { |
|
|
|
// We are in a submodule. The file's contents are `gitdir: <gitFolder>\n`. |
|
|
|
// We are in a submodule. The file's contents are `gitdir: <gitFolder>\n`. |
|
|
|
// Read the file, cut off the front, and trim the whitespace. |
|
|
|
// Read the file, cut off the front, and trim the whitespace. |
|
|
|
gitFolder = file(gitFolder).text.substring(8).trim() + "/" |
|
|
|
gitFolder = file(gitFolder).text.substring(length).trim() + "/" |
|
|
|
} |
|
|
|
} |
|
|
|
def takeFromHash = 8 |
|
|
|
def takeFromHash = length |
|
|
|
/* |
|
|
|
/* |
|
|
|
* '.git/HEAD' contains either |
|
|
|
* '.git/HEAD' contains either |
|
|
|
* in case of detached head: the currently checked out commit hash |
|
|
|
* in case of detached head: the currently checked out commit hash |
|
|
|