Skip to content

Commit

Permalink
Docker Image for EVMTool (#1313)
Browse files Browse the repository at this point in the history
Create a docker image for EVMTool, so that the GoEvmLab tool can easily
integrate the besu EVM into its fuzzing framework.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
  • Loading branch information
shemnon authored Aug 15, 2020
1 parent ac94c76 commit dc20e62
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
62 changes: 62 additions & 0 deletions ethereum/evmtool/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,65 @@ startScripts {
windowsScript.text = windowsScript.text.replace('BESU_HOME', '%~dp0..')
}
}

// rename the top level dir from besu-<version> to besu and this makes it really
// simple for use in docker
tasks.register("dockerDistUntar") {
dependsOn distTar
dependsOn distZip
def dockerBuildDir = "${buildDir}/docker-besu-evmtool"
def distTarFile = distTar.outputs.files.singleFile
def distTarFileName = distTar.outputs.files.singleFile.name.replace(".tar", "")

doFirst {
new File(dockerBuildDir).mkdir()
copy {
from tarTree(distTarFile)
into(dockerBuildDir)
}
file("${dockerBuildDir}/${distTarFileName}").renameTo("${dockerBuildDir}/besu-evmtool")
}
}

task distDocker(type: Exec) {
dependsOn dockerDistUntar
def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}"
def imageName = "hyperledger/besu-evmtool"
def image = "${imageName}:${dockerBuildVersion}"
def dockerBuildDir = "${buildDir}/docker-besu-evmtool/"
workingDir "${dockerBuildDir}"

doFirst {
copy {
from file("${projectDir}/src/main/docker/Dockerfile")
into(workingDir)
}
}

executable "sh"
args "-c", "docker build --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ."
}

task dockerUpload(type: Exec) {
dependsOn distDocker
def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}"
def imageName = "hyperledger/besu-evmtool"
def image = "${imageName}:${dockerBuildVersion}"
def cmd = "docker push '${image}'"
def additionalTags = []

if (project.hasProperty('branch') && project.property('branch') == 'master') {
additionalTags.add('develop')
}

if (!(dockerBuildVersion ==~ /.*-SNAPSHOT/)) {
additionalTags.add('latest')
additionalTags.add(dockerBuildVersion.split(/\./)[0..1].join('.'))
}

additionalTags.each { tag ->
cmd += " && docker tag '${image}' '${imageName}:${tag.trim()}' && docker push '${imageName}:${tag.trim()}'"
}
executable "sh"
args "-c", cmd
}
27 changes: 27 additions & 0 deletions ethereum/evmtool/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

FROM openjdk:11.0.7-jre-slim-buster

RUN adduser --disabled-password --gecos "" --home /opt/besu-evmtool besu && \
chown besu:besu /opt/besu-evmtool

USER besu
WORKDIR /opt/besu-evmtool

COPY --chown=besu:besu besu-evmtool /opt/besu-evmtool/

ENV PATH="/opt/besu-evmtool/bin:${PATH}"
ENTRYPOINT ["evm"]

# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Besu EVMTool" \
org.label-schema.description="EVM Execution Tool" \
org.label-schema.url="https://besu.hyperledger.org/" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/hyperledger/besu.git" \
org.label-schema.vendor="Hyperledger" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"

0 comments on commit dc20e62

Please sign in to comment.