diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3155667b9e6..44e22943a56 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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: diff --git a/build.gradle b/build.gradle index 0feccb1e532..48aea9d8ae2 100644 --- a/build.gradle +++ b/build.gradle @@ -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- to besu and this makes it really // simple for use in docker @@ -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} ." } } } @@ -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}" } + } } @@ -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 @@ -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}" @@ -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}'" @@ -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 = "" diff --git a/docker/openjdk-latest/Dockerfile b/docker/Dockerfile similarity index 100% rename from docker/openjdk-latest/Dockerfile rename to docker/Dockerfile diff --git a/docker/test.sh b/docker/test.sh index 34ce7d3a64e..1d30224f45a 100755 --- a/docker/test.sh +++ b/docker/test.sh @@ -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 @@ -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 @@ -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