Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build arm64 besu docker images #2954

Merged
merged 21 commits into from May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
96 changes: 94 additions & 2 deletions .circleci/config.yml
Expand Up @@ -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
garyschulte marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -373,6 +432,9 @@ workflows:
- buildDocker:
requires:
- assemble
- buildArm64Docker:
requires:
- assemble
- publish:
filters:
branches:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
60 changes: 51 additions & 9 deletions build.gradle
Expand Up @@ -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') {
Expand All @@ -751,28 +752,69 @@ 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
}
}

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
}
}
}

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'

Expand Down
2 changes: 1 addition & 1 deletion docker/test.sh
@@ -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
Expand Down