diff --git a/CHANGELOG.md b/CHANGELOG.md index 572c8682e6..1c96da288d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Additions and Improvements - Updated jackson-databind library to version 2.13.4.2 addressing [CVE-2022-42003](https://nvd.nist.gov/vuln/detail/CVE-2022-42003) +- Gradle task allows custom docker image configs e.g. `./gradlew distDocker -PdockerImageName=my/besu -PdockerVariants=openjdk-17,openjdk-19` ### Bug Fixes - Fixed default fromBlock value and improved parameter interpretation in eth_getLogs RPC handler [#4513](https://github.com/hyperledger/besu/pull/4513) diff --git a/build.gradle b/build.gradle index 0c184613cc..353cf8b43c 100644 --- a/build.gradle +++ b/build.gradle @@ -604,7 +604,9 @@ artifactoryPublish { dependsOn distZip } -def dockerVariants = [ +def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}" +def dockerImageName = project.hasProperty("dockerImageName") ? project.getProperty("dockerImageName") : "hyperledger/besu" +def dockerVariants = project.hasProperty("dockerVariants") ? project.getProperty("dockerVariants").split(",") : [ "openjdk-11", "openjdk-11-debug", "graalvm", @@ -634,9 +636,7 @@ tasks.register("dockerDistUntar") { task distDocker { dependsOn dockerDistUntar inputs.dir("build/docker-besu/") - def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}" def dockerBuildDir = "build/docker-besu/" - def imageName = "hyperledger/besu" doLast { for (def variant in dockerVariants) { @@ -645,7 +645,7 @@ task distDocker { into(dockerBuildDir) } exec { - def image = "${imageName}:${dockerBuildVersion}-${variant}" + def image = "${dockerImageName}:${dockerBuildVersion}-${variant}" executable "sh" workingDir dockerBuildDir args "-c", "docker build --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ." @@ -654,12 +654,12 @@ task distDocker { // tag the "default" (which is the variant in the zero position) exec { executable "sh" - args "-c", "docker tag '${imageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${imageName}:${dockerBuildVersion}'" + args "-c", "docker tag '${dockerImageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${dockerImageName}:${dockerBuildVersion}'" } // create a static tag for the benchmark target exec { executable "sh" - args "-c", "docker tag '${imageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${imageName}:benchmark'" + args "-c", "docker tag '${dockerImageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${dockerImageName}:benchmark'" } } } @@ -675,7 +675,7 @@ task testDocker { doLast { for (def variant in dockerVariants) { exec { - def image = project.hasProperty('release.releaseVersion') ? "hyperledger/besu:" + project.property('release.releaseVersion') : "hyperledger/besu:${project.version}" + def image = project.hasProperty('release.releaseVersion') ? "${dockerImageName}:" + project.property('release.releaseVersion') : "${dockerImageName}:${project.version}" workingDir "${projectDir}/docker/${variant}" executable "sh" args "-c", "bash ../test.sh ${image}-${variant}" @@ -710,7 +710,7 @@ task acceptanceTestsQuorum { new File(dataDirectory).mkdirs() new File(reportsDirectory).mkdirs() - def image = project.hasProperty('release.releaseVersion') ? "hyperledger/besu:" + project.property('release.releaseVersion') : "hyperledger/besu:${project.version}" + def image = project.hasProperty('release.releaseVersion') ? "${dockerImageName}:" + project.property('release.releaseVersion') : "${dockerImageName}:${project.version}" def dockerEnv = "--env LOGGING_LEVEL_COM_QUORUM_GAUGE=DEBUG --env TF_VAR_besu_docker_image='{name=\"${image}-${variant}\",local=true}'" def dockerVolumes = "-v ${reportsDirectory}:/workspace/target/gauge/reports/ -v /var/run/docker.sock:/var/run/docker.sock -v ${dataDirectory}:${dataDirectory}" executable "sh" @@ -719,13 +719,10 @@ task acceptanceTestsQuorum { } } -def dockerImage = "hyperledger/besu" - task dockerUpload { dependsOn distDocker - def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}" def architecture = System.getenv('architecture') - def image = "${dockerImage}:${dockerBuildVersion}" + def image = "${dockerImageName}:${dockerBuildVersion}" def additionalTags = [] if (project.hasProperty('branch') && project.property('branch') == 'main') { @@ -743,7 +740,7 @@ task dockerUpload { exec { def archVariantImage = "${variantImage}-${architecture}" def cmd = "docker tag '${variantImage}' '${archVariantImage}' && docker push '${archVariantImage}'" - additionalTags.each { tag -> cmd += " && docker tag '${variantImage}' '${dockerImage}:${tag.trim()}-${variant}-${architecture}' && docker push '${dockerImage}:${tag.trim()}-${variant}-${architecture}'" } + additionalTags.each { tag -> cmd += " && docker tag '${variantImage}' '${dockerImageName}:${tag.trim()}-${variant}-${architecture}' && docker push '${dockerImageName}:${tag.trim()}-${variant}-${architecture}'" } executable "sh" args "-c", cmd } @@ -752,7 +749,7 @@ task dockerUpload { exec { def archImage = "${image}-${architecture}" def cmd = "docker tag ${image} ${archImage} && docker push '${archImage}'" - additionalTags.each { tag -> cmd += " && docker tag '${image}' '${dockerImage}:${tag.trim()}-${architecture}' && docker push '${dockerImage}:${tag.trim()}-${architecture}'" } + additionalTags.each { tag -> cmd += " && docker tag '${image}' '${dockerImageName}:${tag.trim()}-${architecture}' && docker push '${dockerImageName}:${tag.trim()}-${architecture}'" } executable "sh" args "-c", cmd } @@ -761,18 +758,17 @@ task dockerUpload { task manifestDocker { - def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}" - def image = "${dockerImage}:${dockerBuildVersion}" + def image = "${dockerImageName}:${dockerBuildVersion}" def archs = ["arm64", "amd64"] def tags = ["${image}"] if (project.hasProperty('branch') && project.property('branch') == 'main') { - tags.add("${dockerImage}:develop") + tags.add("${dockerImageName}:develop") } if (!(dockerBuildVersion ==~ /.*-SNAPSHOT/)) { - tags.add("${dockerImage}:latest") - tags.add("${dockerImage}:" + dockerBuildVersion.split(/\./)[0..1].join('.')) + tags.add("${dockerImageName}:latest") + tags.add("${dockerImageName}:" + dockerBuildVersion.split(/\./)[0..1].join('.')) } doLast {