From 8fb4b65ea6b61e69fdaee2be22754cc542ce690e Mon Sep 17 00:00:00 2001 From: 3for <287494524@qq.com> Date: Sun, 22 Nov 2026 13:05:12 +0800 Subject: [PATCH 1/4] fix(docker): upgrade Ubuntu packages before installing dependencies Upgrade packages inherited from the Ubuntu 24.04 base image so fresh builds pick up security fixes on both amd64 and arm64. Fail the build if APT cannot refresh any package index. --- docker/Dockerfile | 7 ++++--- docker/arm64/Dockerfile | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 2f7915e7032..593427a84de 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,9 +8,10 @@ ENV ADOPTIUM_SIGNING_FINGERPRINT="3B04D753C9050D9A5D343F39843C48A565F8F04B" ENV JDK_DIR="/usr/local/openjdk-8" ENV BASE_DIR="/java-tron" -# Update and install dependencies without using any cache -RUN apt-get update $NO_PROXY_CACHE && \ - apt-get --quiet --yes install git 7zip curl jq libtcmalloc-minimal4 gnupg dirmngr ca-certificates && \ +# Apply Ubuntu updates to packages inherited from the base image before installing build tools. +RUN apt-get --error-on=any update $NO_PROXY_CACHE \ + && DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends --with-new-pkgs upgrade \ + && apt-get --quiet --yes install git 7zip curl jq libtcmalloc-minimal4 gnupg dirmngr ca-certificates && \ cd /usr/local \ && FETCH_URL="$(curl -fsS -w "%{redirect_url}" -o /dev/null "$OPENJDK8_URL")" \ && JDK_TAR="$(curl -fsSL -w "%{filename_effective}" -O "$FETCH_URL")" \ diff --git a/docker/arm64/Dockerfile b/docker/arm64/Dockerfile index 8b4601223b6..e7144fe51ed 100644 --- a/docker/arm64/Dockerfile +++ b/docker/arm64/Dockerfile @@ -5,8 +5,9 @@ ENV NO_PROXY_CACHE="-o Acquire::BrokenProxy=true -o Acquire::http::No-Cache=true ENV TMP_DIR="/tron-build" ENV BASE_DIR="/java-tron" -# Update and install dependencies without using any cache -RUN apt-get update $NO_PROXY_CACHE \ +# Apply Ubuntu updates to packages inherited from the base image before installing build tools. +RUN apt-get --error-on=any update $NO_PROXY_CACHE \ + && DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends --with-new-pkgs upgrade \ && apt-get --quiet --yes install git 7zip curl jq libtcmalloc-minimal4 openjdk-17-jre-headless=17* \ && echo "git clone" \ && mkdir -p $TMP_DIR \ From e1aefa724f9cce8cd9c8b19913b293c7118ad8f3 Mon Sep 17 00:00:00 2001 From: 3for <287494524@qq.com> Date: Sun, 22 Nov 2026 13:05:54 +0800 Subject: [PATCH 2/4] build(docker): pin Ubuntu OpenJDK packages for amd64 and arm64 Install OpenJDK 8 from Ubuntu on amd64. Pin the headless JDK and JRE to the same package version, use the JDK to build and unpack java-tron, and point JAVA_HOME at the retained JRE after purging the build tools. Pin the Ubuntu OpenJDK 17 headless JRE on arm64 and use its jdk.jartool module to unpack the distribution. Restore launcher permissions on both architectures and remove the tools used only during the build. --- docker/Dockerfile | 39 +++++++++++++-------------------------- docker/arm64/Dockerfile | 17 +++++++++++------ 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 593427a84de..4e02bb35e6e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,32 +1,17 @@ FROM ubuntu:24.04 ARG VERSION="dev" +ARG OPENJDK_VERSION="8u514-b01~us1-0ubuntu1~24.04.1" ENV NO_PROXY_CACHE="-o Acquire::BrokenProxy=true -o Acquire::http::No-Cache=true -o Acquire::http::Pipeline-Depth=0" ENV TMP_DIR="/tron-build" -ENV OPENJDK8_URL="https://api.adoptium.net/v3/binary/latest/8/ga/linux/x64/jdk/hotspot/normal/eclipse" -ENV ADOPTIUM_SIGNING_FINGERPRINT="3B04D753C9050D9A5D343F39843C48A565F8F04B" -ENV JDK_DIR="/usr/local/openjdk-8" ENV BASE_DIR="/java-tron" +ENV JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" # Apply Ubuntu updates to packages inherited from the base image before installing build tools. RUN apt-get --error-on=any update $NO_PROXY_CACHE \ && DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends --with-new-pkgs upgrade \ - && apt-get --quiet --yes install git 7zip curl jq libtcmalloc-minimal4 gnupg dirmngr ca-certificates && \ - cd /usr/local \ - && FETCH_URL="$(curl -fsS -w "%{redirect_url}" -o /dev/null "$OPENJDK8_URL")" \ - && JDK_TAR="$(curl -fsSL -w "%{filename_effective}" -O "$FETCH_URL")" \ - && curl -fsSLo "$JDK_TAR.sig" "$FETCH_URL.sig" \ - && GNUPGHOME="$(mktemp -d)" \ - && export GNUPGHOME \ - && gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$ADOPTIUM_SIGNING_FINGERPRINT" \ - && gpg --batch --verify "$JDK_TAR.sig" "$JDK_TAR" \ - && rm -rf "$GNUPGHOME" "$JDK_TAR.sig" \ - && mkdir -p "$JDK_DIR" \ - && tar -zxf "$JDK_TAR" -C "$JDK_DIR" --strip-components=1 \ - && rm "$JDK_TAR" \ - && export JAVA_HOME=$JDK_DIR \ - && export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar \ - && export PATH=$PATH:$JAVA_HOME/bin \ + && apt-get --quiet --yes --no-install-recommends install ca-certificates git libtcmalloc-minimal4 \ + "openjdk-8-jdk-headless=$OPENJDK_VERSION" "openjdk-8-jre-headless=$OPENJDK_VERSION" \ && echo "git clone" \ && mkdir -p $TMP_DIR \ && cd $TMP_DIR \ @@ -35,20 +20,22 @@ RUN apt-get --error-on=any update $NO_PROXY_CACHE \ && git checkout master \ && ./gradlew clean build -x test -x check --no-daemon \ && cd build/distributions \ - && 7z x -y java-tron-1.0.0.zip \ - && cp $TMP_DIR/java-tron/framework/src/main/resources/config.conf java-tron-1.0.0/config.conf \ - && mv java-tron-1.0.0 $BASE_DIR \ + && "$JAVA_HOME/bin/jar" xf java-tron-1.0.0.zip \ + && mv java-tron-1.0.0 "$BASE_DIR" \ + && chmod 755 "$BASE_DIR/bin/FullNode" "$BASE_DIR/bin/FullNode.bat" \ + && cp ../../framework/src/main/resources/config.conf "$BASE_DIR/config.conf" \ + && cd / \ && rm -rf $TMP_DIR \ && rm -rf ~/.gradle \ - && mv $JDK_DIR/jre /usr/local \ - && rm -rf $JDK_DIR \ + && apt-get --quiet --yes purge --auto-remove git openjdk-8-jdk-headless \ # Clean apt cache && apt-get clean \ && rm -rf /var/cache/apt/archives/* /var/cache/apt/archives/partial/* \ && rm -rf /var/lib/apt/lists/* -ENV JAVA_HOME="/usr/local/jre" -ENV PATH=$PATH:$JAVA_HOME/bin +# The explicitly installed Java 8 JRE stays in this directory after the JDK is purged. +ENV JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre" +ENV PATH=$JAVA_HOME/bin:$PATH ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4" ENV TCMALLOC_RELEASE_RATE=10 diff --git a/docker/arm64/Dockerfile b/docker/arm64/Dockerfile index e7144fe51ed..b46afcee147 100644 --- a/docker/arm64/Dockerfile +++ b/docker/arm64/Dockerfile @@ -1,14 +1,18 @@ FROM ubuntu:24.04 ARG VERSION="dev" +ARG OPENJDK_VERSION="17.0.21.1+2-1~24.04.1" ENV NO_PROXY_CACHE="-o Acquire::BrokenProxy=true -o Acquire::http::No-Cache=true -o Acquire::http::Pipeline-Depth=0" ENV TMP_DIR="/tron-build" ENV BASE_DIR="/java-tron" +ENV JAVA_HOME="/usr/lib/jvm/java-17-openjdk-arm64" +ENV PATH=$JAVA_HOME/bin:$PATH # Apply Ubuntu updates to packages inherited from the base image before installing build tools. RUN apt-get --error-on=any update $NO_PROXY_CACHE \ && DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends --with-new-pkgs upgrade \ - && apt-get --quiet --yes install git 7zip curl jq libtcmalloc-minimal4 openjdk-17-jre-headless=17* \ + && apt-get --quiet --yes --no-install-recommends install ca-certificates git libtcmalloc-minimal4 \ + "openjdk-17-jre-headless=$OPENJDK_VERSION" \ && echo "git clone" \ && mkdir -p $TMP_DIR \ && cd $TMP_DIR \ @@ -17,18 +21,19 @@ RUN apt-get --error-on=any update $NO_PROXY_CACHE \ && git checkout master \ && ./gradlew clean build -x test -x check --no-daemon \ && cd build/distributions \ - && 7z x -y java-tron-1.0.0.zip \ - && cp $TMP_DIR/java-tron/framework/src/main/resources/config.conf java-tron-1.0.0/config.conf \ - && mv java-tron-1.0.0 $BASE_DIR \ + && java -m jdk.jartool/sun.tools.jar.Main xf java-tron-1.0.0.zip \ + && mv java-tron-1.0.0 "$BASE_DIR" \ + && chmod 755 "$BASE_DIR/bin/FullNode" "$BASE_DIR/bin/FullNode.bat" \ + && cp ../../framework/src/main/resources/config.conf "$BASE_DIR/config.conf" \ + && cd / \ && rm -rf $TMP_DIR \ && rm -rf ~/.gradle \ + && apt-get --quiet --yes purge --auto-remove git \ # Clean apt cache && apt-get clean \ && rm -rf /var/cache/apt/archives/* /var/cache/apt/archives/partial/* \ && rm -rf /var/lib/apt/lists/* -ENV JAVA_HOME="/usr/lib/jvm/java-17-openjdk-arm64" -ENV PATH=$PATH:$JAVA_HOME/bin ENV LD_PRELOAD="/usr/lib/aarch64-linux-gnu/libtcmalloc_minimal.so.4" ENV TCMALLOC_RELEASE_RATE=10 From ac9ca184acf91c5c7cf5337ff78c904b876a7cf0 Mon Sep 17 00:00:00 2001 From: 3for <287494524@qq.com> Date: Sun, 22 Nov 2026 13:06:07 +0800 Subject: [PATCH 3/4] docs(docker): document how to update pinned OpenJDK packages Show how to look up the available Ubuntu package versions for each architecture and test a replacement with the OPENJDK_VERSION build argument. Verify the runtime and FullNode before changing the default. --- docker/docker.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docker/docker.md b/docker/docker.md index 4941139ae64..617e83cd32a 100644 --- a/docker/docker.md +++ b/docker/docker.md @@ -179,6 +179,36 @@ When the script is used from a java-tron checkout, only the Dockerfile and build Standalone `--build` using only a downloaded `docker.sh` is currently unavailable. The helper downloads only the architecture-specific Dockerfile from `develop`, but the current `develop` Dockerfiles also require `docker-entrypoint.sh`, which is missing from the temporary build context. Use a complete checkout containing the matching Dockerfiles until those files are synchronized to `develop` and standalone builds are verified for both architectures. +### Update a pinned OpenJDK package + +Each Dockerfile pins an exact OpenJDK package version from the Ubuntu 24.04 repositories. When Ubuntu replaces that version in the package index, a fresh build for the affected architecture can fail with `Version ... was not found`. Check the versions available for that architecture. + +```shell +# amd64 requires the same version of both Java 8 packages +docker run --rm --platform linux/amd64 ubuntu:24.04 sh -ec \ + 'apt-get --error-on=any update -qq && apt-cache madison openjdk-8-jdk-headless openjdk-8-jre-headless' + +# arm64 uses the Java 17 runtime +docker run --rm --platform linux/arm64 ubuntu:24.04 sh -ec \ + 'apt-get --error-on=any update -qq && apt-cache madison openjdk-17-jre-headless' +``` + +Choose the full version from the second column, including the Ubuntu revision. For a security update, check the fixed version for Ubuntu 24.04 in the relevant [Ubuntu Security Notice](https://ubuntu.com/security/notices). From the repository root, substitute the chosen version in the build command for the affected architecture. + +```shell +# amd64 +docker build --no-cache --platform linux/amd64 \ + --build-arg OPENJDK_VERSION='' \ + -f docker/Dockerfile -t java-tron:check-amd64 docker + +# arm64 +docker build --no-cache --platform linux/arm64 \ + --build-arg OPENJDK_VERSION='' \ + -f docker/arm64/Dockerfile -t java-tron:check-arm64 docker +``` + +Verify the runtime with `docker run --rm --platform --entrypoint java -version` and confirm FullNode starts with your usual configuration. Then update the `ARG OPENJDK_VERSION` default in the corresponding Dockerfile so subsequent builds use the verified version. + ## Options ### Commands From a29e447819e0b345f95a6f214c1da6f1cc143e4a Mon Sep 17 00:00:00 2001 From: 3for <287494524@qq.com> Date: Mon, 23 Nov 2026 15:32:51 +0800 Subject: [PATCH 4/4] feat(docker): allow overriding the pinned OpenJDK version in docker.sh --- docker/docker.md | 10 +++++++++- docker/docker.sh | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docker/docker.md b/docker/docker.md index 617e83cd32a..fdfdb9ea1cd 100644 --- a/docker/docker.md +++ b/docker/docker.md @@ -159,6 +159,14 @@ $ bash docker.sh --build amd64 $ bash docker.sh --build arm64 ``` +To override the pin for one build, set `OPENJDK_VERSION` to the full Ubuntu package version for the target architecture. + +```shell +OPENJDK_VERSION='' bash docker.sh --build arm64 +``` + +A successful build updates the local `tronprotocol/java-tron:latest` tag used by `--run`. To test a candidate version under a separate tag, follow [Update a pinned OpenJDK package](#update-a-pinned-openjdk-package). + Building for an architecture different from the Docker daemon requires a builder with the corresponding emulation support. Docker Desktop provides this by default; standalone Docker Engine installations may require QEMU/binfmt configuration. Docker may reuse cached layers, so rebuilding does not necessarily fetch the latest remote `master`. To fetch the source again, run one of the following commands from the java-tron repository root. The helper does not accept `--no-cache`; use Docker directly: @@ -213,7 +221,7 @@ Verify the runtime with `docker run --rm --platform --entrypoint java ### Commands -- **`--build [amd64|arm64]`**: build `tronprotocol/java-tron:latest` from the remote `master` branch, optionally for the specified architecture +- **`--build [amd64|arm64]`**: build `tronprotocol/java-tron:latest` from the remote `master` branch, optionally for the specified architecture. Set `OPENJDK_VERSION` to override the pinned Ubuntu OpenJDK package version for that build. - **`--pull`**: download `tronprotocol/java-tron:latest` from Docker Hub - **`--run`**: run `tronprotocol/java-tron:latest` - **`--start`**: start the existing java-tron container diff --git a/docker/docker.sh b/docker/docker.sh index 0a9f511d0b9..a5b4e9eb73e 100644 --- a/docker/docker.sh +++ b/docker/docker.sh @@ -314,6 +314,7 @@ build() { local build_context="$SCRIPT_DIR" local temporary_context="" local build_status + local -a build_args=() if [[ $# -gt 1 ]]; then echo "build: expected at most one architecture argument" >&2 @@ -363,11 +364,17 @@ build() { fi fi + if [[ -n "${OPENJDK_VERSION:-}" ]]; then + build_args+=(--build-arg "OPENJDK_VERSION=$OPENJDK_VERSION") + printf 'build: overriding OPENJDK_VERSION=%q for %s\n' "$OPENJDK_VERSION" "$platform" + fi + echo "docker build --platform $platform --file $dockerfile_path" docker build \ --platform "$platform" \ --file "$dockerfile_path" \ --tag "$IMAGE_REFERENCE" \ + "${build_args[@]}" \ "$build_context" build_status=$?