Skip to content

Commit

Permalink
reduce number of jvms provided
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Florentine <justin+github@florentine.us>
  • Loading branch information
jflo committed Apr 2, 2024
1 parent 2658059 commit fa875b7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 115 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,8 @@ jobs:
uses: gradle/actions/setup-gradle@9e899d11ad247ec76be7a60bc1cf9d3abbb9e7f1
with:
cache-disabled: true
- name: hadoLint_openj9-jdk_17
run: docker run --rm -i hadolint/hadolint < docker/openj9-jdk-17/Dockerfile
- name: hadoLint_openjdk_17
run: docker run --rm -i hadolint/hadolint < docker/openjdk-17/Dockerfile
- name: hadoLint_openjdk_17_debug
run: docker run --rm -i hadolint/hadolint < docker/openjdk-17-debug/Dockerfile
- name: hadoLint_openjdk_latest
run: docker run --rm -i hadolint/hadolint < docker/openjdk-latest/Dockerfile
- name: hadoLint_graalvm
run: docker run --rm -i hadolint/hadolint < docker/graalvm/Dockerfile
buildDocker:
needs: hadolint
permissions:
Expand Down
155 changes: 51 additions & 104 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,6 @@ def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project
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(",") : [
"openjdk-17",
"openjdk-17-debug",
"openj9-jdk-17",
"graalvm",
"openjdk-latest"
]

// rename the top level dir from besu-<version> to besu and this makes it really
// simple for use in docker
Expand Down Expand Up @@ -754,34 +747,21 @@ task distDocker {
def dockerBuildDir = "build/docker-besu/"

doLast {
for (def jvmVariant in dockerVariants) {
copy {
from file("${projectDir}/docker/${jvmVariant}/Dockerfile")
into(dockerBuildDir)
}
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')}"
}
def gitDetails = getGitCommitDetails(10)
executable shell
workingDir dockerBuildDir
args "-c", "docker build ${dockerPlatform} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${gitDetails.hash} -t ${image} ."
}
}

// tag the "default" (which is the variant in the zero position)
exec {
executable shell
args "-c", "docker tag '${dockerImageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${dockerImageName}:${dockerBuildVersion}'"
copy {
from file("${projectDir}/docker/Dockerfile")
into(dockerBuildDir)
}
// create a static tag for the benchmark target
exec {
def image = "${dockerImageName}:${dockerBuildVersion}"
def dockerPlatform = ""
if (project.hasProperty('docker-platform')){
dockerPlatform = "--platform ${project.getProperty('docker-platform')}"
println "Building for platform ${project.getProperty('docker-platform')}"
}
def gitDetails = getGitCommitDetails(10)
executable shell
args "-c", "docker tag '${dockerImageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${dockerImageName}:benchmark'"
workingDir dockerBuildDir
args "-c", "docker build ${dockerPlatform} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${gitDetails.hash} -t ${image} ."
}
}
}
Expand All @@ -795,14 +775,13 @@ task testDocker {
}

doLast {
for (def variant in dockerVariants) {
exec {
def image = project.hasProperty('release.releaseVersion') ? "${dockerImageName}:" + project.property('release.releaseVersion') : "${dockerImageName}:${project.version}"
workingDir "${projectDir}/docker/${variant}"
executable shell
args "-c", "../test.sh ${image}-${variant}"
}
exec {
def image = project.hasProperty('release.releaseVersion') ? "${dockerImageName}:" + project.property('release.releaseVersion') : "${dockerImageName}:${project.version}"
workingDir "${projectDir}/docker"
executable shell
args "-c", "./test.sh ${image}"
}

}
}

Expand All @@ -821,22 +800,9 @@ task dockerUpload {
}

doLast {
for (def variant in dockerVariants) {
def variantImage = "${image}-${variant}"
exec {
def archVariantImage = "${variantImage}-${architecture}"
def cmd = "docker tag '${variantImage}' '${archVariantImage}' && docker push '${archVariantImage}'"
additionalTags.each { tag -> cmd += " && docker tag '${variantImage}' '${dockerImageName}:${tag.trim()}-${variant}-${architecture}' && docker push '${dockerImageName}:${tag.trim()}-${variant}-${architecture}'" }
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
}

exec {
def archImage = "${image}-${architecture}"
def cmd = "docker tag ${image} ${archImage} && docker push '${archImage}'"
additionalTags.each { tag -> cmd += " && docker tag '${image}' '${dockerImageName}:${tag.trim()}-${architecture}' && docker push '${dockerImageName}:${tag.trim()}-${architecture}'" }
def archVariantImage = "${image}-${architecture}"
def cmd = "docker tag '${image}' '${archVariantImage}' && docker push '${archVariantImage}'"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
Expand All @@ -850,21 +816,20 @@ task dockerUploadRelease {

doLast {
for (def architecture in archs) {
for (def variant in dockerVariants) {
def variantImage = "${image}-${variant}"
exec {
def cmd = "docker pull '${variantImage}-${architecture}' && docker tag '${variantImage}-${architecture}' '${dockerImageName}:latest-${variant}-${architecture}'"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
exec {
def cmd = "docker push '${dockerImageName}:latest-${variant}-${architecture}'"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}

exec {
def cmd = "docker pull '${image}-${architecture}' && docker tag '${image}-${architecture}' '${dockerImageName}:latest-${architecture}'"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
exec {
def cmd = "docker push '${dockerImageName}:latest-${architecture}'"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}


exec {
def archImage = "${image}-${architecture}"
Expand Down Expand Up @@ -898,27 +863,27 @@ task manifestDocker {

doLast {
for (baseTag in tags) {
for (def variant in dockerVariants) {
def variantImage = "${baseTag}-${variant}"
def targets = ""
archs.forEach { arch -> targets += "'${variantImage}-${arch}' " }

exec {
def cmd = "docker manifest create '${variantImage}' ${targets}"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
exec {
def cmd = "docker manifest push '${variantImage}'"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
//for (def variant in dockerVariants) {
//def variantImage = "${baseTag}-${variant}"
def targets = ""
archs.forEach { arch -> targets += "'${image}-${arch}' " }

exec {
def cmd = "docker manifest create '${image}' ${targets}"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
exec {
def cmd = "docker manifest push '${image}'"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
//}

exec {
def targets = ""
targets = ""
archs.forEach { arch -> targets += "'${baseTag}-${arch}' " }
def cmd = "docker manifest create '${baseTag}' ${targets}"
println "Executing '${cmd}'"
Expand All @@ -940,24 +905,6 @@ task manifestDockerRelease {
def baseTag = "${dockerImageName}:latest";

doLast {
for (def variant in dockerVariants) {
def variantImage = "${baseTag}-${variant}"
def targets = ""
archs.forEach { arch -> targets += "'${variantImage}-${arch}' " }

exec {
def cmd = "docker manifest create '${variantImage}' ${targets} --amend"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
exec {
def cmd = "docker manifest push '${variantImage}'"
println "Executing '${cmd}'"
executable shell
args "-c", cmd
}
}

exec {
def targets = ""
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions docker/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

export TEST_PATH=../tests
export TEST_PATH=./tests
export GOSS_PATH=$TEST_PATH/goss-linux-${architecture}
export GOSS_OPTS="$GOSS_OPTS --format junit"
export GOSS_FILES_STRATEGY=cp
Expand All @@ -12,7 +12,7 @@ i=0
## Checks on the Dockerfile
GOSS_FILES_PATH=$TEST_PATH/00 \
bash $TEST_PATH/dgoss dockerfile $DOCKER_IMAGE $DOCKER_FILE \
> ../reports/00.xml || i=`expr $i + 1`
> ./reports/00.xml || i=`expr $i + 1`
# fail fast if we dont pass static checks
if [[ $i != 0 ]]; then exit $i; fi

Expand All @@ -25,6 +25,6 @@ bash $TEST_PATH/dgoss run $DOCKER_IMAGE \
--rpc-http-enabled \
--rpc-ws-enabled \
--graphql-http-enabled \
> ../reports/01.xml || i=`expr $i + 1`
> ./reports/01.xml || i=`expr $i + 1`

exit $i

0 comments on commit fa875b7

Please sign in to comment.