Skip to content

Commit

Permalink
dockerfile and github token hackery to build image (build fails for l…
Browse files Browse the repository at this point in the history
…inea until merge of hyperledger#5440)

Signed-off-by: garyschulte <garyschulte@gmail.com>
  • Loading branch information
garyschulte committed May 10, 2023
1 parent 94156ff commit 668948f
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,15 @@ artifactoryPublish {
dependsOn distZip
}

// pass -PgithubToken=username:<YOUR_GITHUB_TOKEN> to gradle to specify a github token:
def githubToken = project.hasProperty('githubToken') ? project.property('githubToken') : "${rootProject.githubToken}"

def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}"
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(",") : [
"linea-state-management", //TODO: do not merge linea docker container
"openjdk-17",
"openjdk-17-debug",
"openj9-jdk-17",
Expand Down Expand Up @@ -693,7 +697,7 @@ task distDocker {
}
executable "sh"
workingDir dockerBuildDir
args "-c", "docker build ${dockerPlatform} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ."
args "-c", "docker build ${dockerPlatform} --build-arg GITHUB_TOKEN=${githubToken} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ."
}
}

Expand Down
88 changes: 88 additions & 0 deletions docker/linea-state-management/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
FROM ubuntu:22.04
##################################################################
# TODO: Do not merge this docker file, it is a convenience for
# building linea and will not work without github auth
##################################################################
ARG VERSION="dev"
ARG TARGETPLATFORM

# Accept the token as a build argument and set it as an environment variable
ARG GITHUB_TOKEN
ENV GITHUB_TOKEN=$GITHUB_TOKEN

RUN apt-get update && \
apt-get install --no-install-recommends -q --assume-yes curl=7* libjemalloc-dev=5.* git ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "aarch64" ]; then \
curl -kL -o jdk-17.tar.gz https://github.com/ibmruntimes/semeru17-binaries/releases/download/jdk-17.0.5%2B8_openj9-0.35.0/ibm-semeru-open-jdk_aarch64_linux_17.0.5_8_openj9-0.35.0.tar.gz ; \
elif [ "$(uname -s)" = "Darwin" ] && [ "$(uname -m)" = "arm64" ]; then \
curl -kL -o jdk-17.tar.gz https://github.com/ibmruntimes/semeru17-binaries/releases/download/jdk-17.0.5%2B8_openj9-0.35.0/ibm-semeru-open-jdk_aarch64_linux_17.0.5_8_openj9-0.35.0.tar.gz ; \
elif [ "$ARCH" = "x86_64" ]; then \
curl -kL -o jdk-17.tar.gz https://github.com/ibmruntimes/semeru17-binaries/releases/download/jdk-17.0.5%2B8_openj9-0.35.0/ibm-semeru-open-jdk_x64_linux_17.0.5_8_openj9-0.35.0.tar.gz ; \
else \
echo "Unsupported platform: $ARCH"; exit 1; \
fi

RUN tar -xzf jdk-17.tar.gz && \
rm jdk-17.tar.gz && \
mv jdk-17.0.5+8 /usr/bin/ && \
update-alternatives --install "/usr/bin/java" "java" "/usr/bin/jdk-17.0.5+8/bin/java" 1 && \
adduser --disabled-password --gecos "" --home /opt/besu besu && \
chown besu:besu /opt/besu && \
chmod 0755 /opt/besu

ENV JAVA_HOME /usr/bin/jdk-17.0.5+8/
RUN export JAVA_HOME

USER besu
WORKDIR /opt/besu

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

# build besu-shomei plugin :
RUN mkdir /opt/besu/plugins && \
mkdir /opt/besu/build-plugin && cd /opt/besu/build-plugin && \
git clone https://${GITHUB_TOKEN}@github.com/ConsenSys/besu-shomei-plugin.git && \
cd besu-shomei-plugin && \
./gradlew plugin && \
cp build/libs/besu-shomei-plugin-*.jar /opt/besu/plugins && \
cd .. && rm -rf build-plugin

# Expose services ports
# 8545 HTTP JSON-RPC
# 8546 WS JSON-RPC
# 8547 HTTP GraphQL
# 8550 HTTP ENGINE JSON-RPC
# 8551 WS ENGINE JSON-RPC
# 30303 P2P
EXPOSE 8545 8546 8547 8550 8551 30303

# defaults for host interfaces
ENV BESU_RPC_HTTP_HOST 0.0.0.0
ENV BESU_RPC_WS_HOST 0.0.0.0
ENV BESU_GRAPHQL_HTTP_HOST 0.0.0.0
ENV BESU_PID_PATH "/tmp/pid"

ENV OTEL_RESOURCE_ATTRIBUTES="service.name=besu,service.version=$VERSION"

ENV OLDPATH="${PATH}"
ENV PATH="/opt/besu/bin:${OLDPATH}"

ENTRYPOINT ["besu"]
HEALTHCHECK --start-period=5s --interval=5s --timeout=1s --retries=10 CMD bash -c "[ -f /tmp/pid ]"

# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
ARG VCS_REF
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Besu" \
org.label-schema.description="Enterprise Ethereum client" \
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 668948f

Please sign in to comment.