From ec7fc4781af063069e56939aef860b8118831be3 Mon Sep 17 00:00:00 2001 From: Justin Florentine Date: Thu, 4 Nov 2021 11:54:08 -0400 Subject: [PATCH] 2936 debug docker build (#2962) * adds a new docker build focusing on providing tools for debugging * updates the latest build to only include a jvm, not a full jdk as shipped for Java 17 Signed-off-by: Justin Florentine --- .circleci/config.yml | 4 ++ build.gradle | 1 + docker/openjdk-11-debug/Dockerfile | 62 ++++++++++++++++++++++++++++++ docker/openjdk-11/Dockerfile | 2 +- docker/openjdk-latest/Dockerfile | 8 +++- 5 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 docker/openjdk-11-debug/Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml index 85a269b102..2547305ed3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -229,6 +229,10 @@ jobs: name: hadoLint_openjdk_11 command: | docker run --rm -i hadolint/hadolint < docker/openjdk-11/Dockerfile + - run: + name: hadoLint_openjdk_11_debug + command: | + docker run --rm -i hadolint/hadolint < docker/openjdk-11-debug/Dockerfile - run: name: hadoLint_openjdk_latest command: | diff --git a/build.gradle b/build.gradle index 24aa624e18..c970e9034c 100644 --- a/build.gradle +++ b/build.gradle @@ -613,6 +613,7 @@ artifactoryPublish { def dockerVariants = [ "openjdk-11", + "openjdk-11-debug", "graalvm", "openjdk-latest" ] diff --git a/docker/openjdk-11-debug/Dockerfile b/docker/openjdk-11-debug/Dockerfile new file mode 100644 index 0000000000..44d4ce0c68 --- /dev/null +++ b/docker/openjdk-11-debug/Dockerfile @@ -0,0 +1,62 @@ + +FROM openjdk:11-slim-buster + +ARG VERSION="dev" +RUN apt-get update && \ + apt-get install --no-install-recommends -q --assume-yes curl=7* wget=1.20* jq=1.5* net-tools=1.60* && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + adduser --disabled-password --gecos "" --home /opt/besu besu && \ + chown besu:besu /opt/besu + +USER besu +WORKDIR /opt/besu + +COPY --chown=besu:besu besu /opt/besu/ + +# Expose services ports +# 5005 JDWP for attaching remote debuggers +# 8545 HTTP JSON-RPC +# 8546 WS JSON-RPC +# 8547 HTTP GraphQL +# 9545 Metrics +# 1098 JMX / JMX-RMI +# 30303 P2P +EXPOSE 5005 8545 8546 8547 9545 1098 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_METRICS_HOST 0.0.0.0 +ENV BESU_JMX_HOST 0.0.0.0 +ENV BESU_PID_PATH "/tmp/pid" +ENV BESU_HOST_ALLOWLIST "*" + +#debug options for maximum observability +ENV BESU_LOGGING "DEBUG" +ENV BESU_RPC_HTTP_API "ETH,NET,TRACE,DEBUG,ADMIN,TXPOOL" +ENV JDWP_OPTS "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" +ENV NATIVE_MEMORY_OPTS "-XX:NativeMemoryTracking=detail -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMTStatistics" +ENV JAVA_OPTS "${JDWP_OPTS} ${NATIVE_MEMORY_OPTS} " + +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" diff --git a/docker/openjdk-11/Dockerfile b/docker/openjdk-11/Dockerfile index ae962eb260..a7786364f5 100644 --- a/docker/openjdk-11/Dockerfile +++ b/docker/openjdk-11/Dockerfile @@ -1,5 +1,5 @@ -FROM openjdk:11-slim-buster +FROM openjdk:11-jre-slim-buster ARG VERSION="dev" diff --git a/docker/openjdk-latest/Dockerfile b/docker/openjdk-latest/Dockerfile index 02af8c3089..77c3444d53 100644 --- a/docker/openjdk-latest/Dockerfile +++ b/docker/openjdk-latest/Dockerfile @@ -1,8 +1,12 @@ -FROM openjdk:slim-buster +FROM debian:bullseye-slim ARG VERSION="dev" -RUN adduser --disabled-password --gecos "" --home /opt/besu besu && \ +RUN apt-get update && \ + apt-get install --no-install-recommends -q --assume-yes openjdk-17-jre-headless=17* && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + adduser --disabled-password --gecos "" --home /opt/besu besu && \ chown besu:besu /opt/besu USER besu