Build arm64 besu docker images (#2954)

* first pass at building arm64 besu docker images
* add arch to docker publish
* add architecture envars to executors
* first pass at manifest docker
* setup docker in manifest step
* add base image to manifestDocker
* add changelog

Signed-off-by: garyschulte <garyschulte@gmail.com>
pull/3811/head
garyschulte 3 years ago committed by GitHub
parent d01b498ebe
commit 1efe1f01a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 96
      .circleci/config.yml
  2. 1
      CHANGELOG.md
  3. 60
      build.gradle
  4. 2
      docker/test.sh

@ -18,6 +18,16 @@ executors:
resource_class: medium
working_directory: ~/project
environment:
architecture: "amd64"
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=2
besu_arm64_executor_med: # 2cpu, 8G ram
machine:
image: ubuntu-2004:202101-01
resource_class: arm.medium
working_directory: ~/project
environment:
architecture: "arm64"
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=2
besu_executor_xl: # 8cpu, 16G ram
@ -318,6 +328,35 @@ jobs:
curl -L https://github.com/aelsabbahy/goss/releases/download/v0.3.9/goss-linux-amd64 -o ./docker/tests/goss-linux-amd64
./gradlew --no-daemon testDocker
buildArm64Docker:
executor: besu_arm64_executor_med
steps:
- prepare
- attach_workspace:
at: ~/project
- run:
name: hadoLint_openjdk_11
command: |
docker run --rm -i hadolint/hadolint < docker/openjdk-11/Dockerfile
- run:
name: hadoLint_openjdk_latest
command: |
docker run --rm -i hadolint/hadolint < docker/openjdk-latest/Dockerfile
- run:
name: hadoLint_graalvm
command: |
docker run --rm -i hadolint/hadolint < docker/graalvm/Dockerfile
- run:
name: build image
command: |
./gradlew --no-daemon distDocker
- run:
name: test image
command: |
mkdir -p docker/reports
curl -L https://github.com/aelsabbahy/goss/releases/download/v0.3.9/goss-linux-arm -o ./docker/tests/goss-linux-arm64
./gradlew --no-daemon testDocker
publish:
executor: besu_executor_med
steps:
@ -340,10 +379,30 @@ jobs:
name: Publish Docker
command: |
docker login --username "${DOCKER_USER_RW}" --password "${DOCKER_PASSWORD_RW}"
# temporarily commented out because AWS credentials are broken
# docker login "${ACR_REPO}" --username "${ACR_USER_RW}" --password "${ACR_PASSWORD_RW}"
./gradlew --no-daemon "-Pbranch=${CIRCLE_BRANCH}" dockerUpload
publishArm64Docker:
executor: besu_arm64_executor_med
steps:
- prepare
- attach_workspace:
at: ~/project
- run:
name: Publish Docker
command: |
docker login --username "${DOCKER_USER_RW}" --password "${DOCKER_PASSWORD_RW}"
./gradlew --no-daemon "-Pbranch=${CIRCLE_BRANCH}" dockerUpload
manifestDocker:
executor: besu_executor_med
steps:
- prepare
- setup_remote_docker
- run:
name: Create and publish docker manifest
command: |
docker login --username "${DOCKER_USER_RW}" --password "${DOCKER_PASSWORD_RW}"
./gradlew --no-daemon --parallel manifestDocker
workflows:
version: 2
default:
@ -373,6 +432,9 @@ workflows:
- buildDocker:
requires:
- assemble
- buildArm64Docker:
requires:
- assemble
- publish:
filters:
branches:
@ -403,6 +465,36 @@ workflows:
- besu-dockerhub-ro
- besu-dockerhub-rw
- besu-acr-rw
- publishArm64Docker:
filters:
branches:
only:
- main
- /^release-.*/
requires:
- integrationTests
- unitTests
- acceptanceTests
- referenceTests
- buildArm64Docker
context:
- besu-dockerhub-ro
- besu-dockerhub-rw
- besu-acr-rw
- manifestDocker:
filters:
branches:
only:
- master
- /^release-.*/
requires:
- publishDocker
- publishArm64Docker
context:
- besu-dockerhub-ro
- besu-dockerhub-rw
- besu-acr-rw
nightly:
triggers:
- schedule:

@ -4,6 +4,7 @@
### Additions and Improvements
- GraphQL - allow null log topics in queries which match any topic [#3662](https://github.com/hyperledger/besu/pull/3662)
- multi-arch docker builds for amd64 and arm64 [#2954](https://github.com/hyperledger/besu/pull/2954)
## 22.4.0

@ -730,12 +730,13 @@ task acceptanceTestsQuorum {
}
}
def dockerImage = "hyperledger/besu"
task dockerUpload {
dependsOn distDocker
def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}"
def imageName = "hyperledger/besu"
def azureImageName = "hyperledger.azurecr.io/besu"
def image = "${imageName}:${dockerBuildVersion}"
def architecture = System.getenv('architecture')
def image = "${dockerImage}:${dockerBuildVersion}"
def additionalTags = []
if (project.hasProperty('branch') && project.property('branch') == 'main') {
@ -751,9 +752,10 @@ task dockerUpload {
for (def variant in dockerVariants) {
def variantImage = "${image}-${variant}"
exec {
def cmd = "docker push '${variantImage}'"
def archVariantImage = "${variantImage}-${architecture}"
def cmd = "docker tag '${variantImage}' '${archVariantImage}' && docker push '${archVariantImage}'"
additionalTags.each { tag ->
cmd += " && docker tag '${variantImage}' '${imageName}:${tag.trim()}-${variant}' && docker push '${imageName}:${tag.trim()}-${variant}'"
cmd += " && docker tag '${variantImage}' '${dockerImage}:${tag.trim()}-${variant}-${architecture}' && docker push '${dockerImage}:${tag.trim()}-${variant}-${architecture}'"
}
executable "sh"
args "-c", cmd
@ -761,11 +763,10 @@ task dockerUpload {
}
exec {
def cmd = "docker push '${image}'"
def archImage = "${image}-${architecture}"
def cmd = "docker tag ${image} ${archImage} && docker push '${archImage}'"
additionalTags.each { tag ->
cmd += " && docker tag '${image}' '${imageName}:${tag.trim()}' && docker push '${imageName}:${tag.trim()}'"
// temporarily commented out because AWS credentials are broken
// cmd += " && docker tag '${image}' '${azureImageName}:${tag.trim()}' && docker push '${azureImageName}:${tag.trim()}'"
cmd += " && docker tag '${image}' '${dockerImage}:${tag.trim()}-${architecture}' && docker push '${dockerImage}:${tag.trim()}-${architecture}'"
}
executable "sh"
args "-c", cmd
@ -773,6 +774,47 @@ task dockerUpload {
}
}
task manifestDocker {
def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}"
def image = "${dockerImage}:${dockerBuildVersion}"
def archs = ["arm64", "amd64"]
def tags = ["${image}"]
if (project.hasProperty('branch') && project.property('branch') == 'main') {
tags.add("${dockerImage}-develop")
}
if (!(dockerBuildVersion ==~ /.*-SNAPSHOT/)) {
tags.add('${dockerImage}-latest')
tags.add('${dockerImage}-' + dockerBuildVersion.split(/\./)[0..1].join('.'))
}
doLast {
for (baseTag in tags) {
for (def variant in dockerVariants) {
// Just do variant images for now, later add tags and such
def variantImage = "${baseTag}-${variant}"
def targets = ""
archs.forEach { arch -> targets += "'${variantImage}-${arch}' " }
exec {
def cmd = "docker manifest create '${variantImage}' ${targets} && docker manifest push '${variantImage}'"
executable "sh"
args "-c", cmd
}
}
exec {
def targets = ""
archs.forEach { arch -> targets += "'${baseTag}-${arch}' " }
def cmd = "docker manifest create '${baseTag}' ${targets} && docker manifest push '${baseTag}'"
executable "sh"
args "-c", cmd
}
}
}
}
task checkSpdxHeader(type: CheckSpdxHeader) {
apply plugin: 'groovy'

@ -1,7 +1,7 @@
#!/bin/bash
export TEST_PATH=../tests
export GOSS_PATH=$TEST_PATH/goss-linux-amd64
export GOSS_PATH=$TEST_PATH/goss-linux-${architecture}
export GOSS_OPTS="$GOSS_OPTS --format junit"
export GOSS_FILES_STRATEGY=cp
DOCKER_IMAGE=$1

Loading…
Cancel
Save