From ad3aac555d93fca70cd6c9722d16e35f3882ed63 Mon Sep 17 00:00:00 2001 From: imbajin Date: Sun, 12 Jul 2026 16:45:16 +0800 Subject: [PATCH 1/2] fix(hubble): avoid emulated image build - pin the Maven and Node build stage to BUILDPLATFORM - cache the package installation layer before source changes - exclude unrelated modules and generated artifacts from context - preserve reactor POMs and Hubble release license files --- .dockerignore | 39 +++++++++++++++++++++++++++++++++++++ hugegraph-hubble/Dockerfile | 5 +++-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..af6405a34 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,39 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Version-control and local development metadata +.git +.github +.idea +.vscode +.codex-task +**/.DS_Store + +# Build outputs and dependency caches +**/target +**/node_modules +**/.cache + +# Modules not used by the Hubble image build. Keep the Maven module POMs so +# the root reactor can still be parsed, and keep release docs used by hubble-dist. +hugegraph-client-go +hugegraph-spark-connector/** +!hugegraph-spark-connector/pom.xml +hugegraph-tools/** +!hugegraph-tools/pom.xml +hugegraph-dist/** +!hugegraph-dist/pom.xml +!hugegraph-dist/release-docs/ +!hugegraph-dist/release-docs/** diff --git a/hugegraph-hubble/Dockerfile b/hugegraph-hubble/Dockerfile index 4591715d7..97f72ed57 100644 --- a/hugegraph-hubble/Dockerfile +++ b/hugegraph-hubble/Dockerfile @@ -15,13 +15,12 @@ # limitations under the License. # -FROM maven:3.9.0-eclipse-temurin-11 AS build +FROM --platform=$BUILDPLATFORM maven:3.9.0-eclipse-temurin-11 AS build ENV NODE_OPTIONS=--dns-result-order=ipv4first ARG MAVEN_ARGS -COPY . /pkg WORKDIR /pkg RUN set -x \ @@ -30,6 +29,8 @@ RUN set -x \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* +COPY . /pkg + RUN set -x \ && mvn install $MAVEN_ARGS -pl hugegraph-client,hugegraph-loader -am -Dmaven.javadoc.skip=true -DskipTests -ntp \ && cd /pkg/hugegraph-hubble/ \ From 563aa1de90e23a16b66b6b362307fcbd8e105a26 Mon Sep 17 00:00:00 2001 From: imbajin Date: Sun, 12 Jul 2026 17:47:45 +0800 Subject: [PATCH 2/2] fix(loader): avoid duplicate emulated build - build the Java distribution once on BUILDPLATFORM - collapse duplicate Maven packaging into one reactor build - cache target-platform package installation independently - document multi-platform build and native library boundaries --- README.md | 20 ++++++++++++++++++-- hugegraph-loader/Dockerfile | 16 ++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 322e6bda5..7846c33f0 100644 --- a/README.md +++ b/README.md @@ -406,12 +406,28 @@ docker run --rm \ Build images locally: ```bash # Loader -cd hugegraph-loader && docker build -t hugegraph/hugegraph-loader:latest . +docker build -f hugegraph-loader/Dockerfile \ + -t hugegraph/hugegraph-loader:latest . # Hubble -cd hugegraph-hubble && docker build -t hugegraph/hugegraph-hubble:latest . +docker build -f hugegraph-hubble/Dockerfile \ + -t hugegraph/hugegraph-hubble:latest . ``` +Multi-platform builds use BuildKit's automatic platform arguments. The Maven +and Node build stages run on `$BUILDPLATFORM`, while the final JRE stage uses +`$TARGETPLATFORM`. Java bytecode and frontend assets are architecture-neutral, +so they are built once without QEMU. Target-stage package installation still +runs for each architecture. + +This optimization applies only to architecture-independent build outputs. A +component that compiles native code must use a target-platform build stage or +separate platform stages. Loader and Hubble packaging is validated on arm64; +native dependencies must still be audited. Loader includes arm64 variants for +Snappy, LZ4, Commons Crypto, and gRPC tcnative. Some optional legacy HBase and +Jansi natives remain x86-only, so their fallback paths require target-runtime +validation when those optional features are used. + ## Documentation - [HugeGraph Toolchain Overview](https://hugegraph.apache.org/docs/quickstart/) diff --git a/hugegraph-loader/Dockerfile b/hugegraph-loader/Dockerfile index 85f609296..0f68f4be9 100644 --- a/hugegraph-loader/Dockerfile +++ b/hugegraph-loader/Dockerfile @@ -15,7 +15,7 @@ # limitations under the License. # -FROM maven:3.9.0-eclipse-temurin-11 AS build +FROM --platform=$BUILDPLATFORM maven:3.9.0-eclipse-temurin-11 AS build COPY . /pkg WORKDIR /pkg @@ -23,18 +23,11 @@ WORKDIR /pkg ARG MAVEN_ARGS RUN set -x \ - && mvn install $MAVEN_ARGS -pl hugegraph-client,hugegraph-loader -am -Dmaven.javadoc.skip=true -DskipTests -ntp - -RUN set -x \ - && cd /pkg/hugegraph-loader/ \ - && echo "$(ls)" \ - && mvn clean package $MAVEN_ARGS -DskipTests + && mvn clean package $MAVEN_ARGS -pl hugegraph-client,hugegraph-loader -am \ + -Dmaven.javadoc.skip=true -DskipTests -ntp FROM eclipse-temurin:11-jre-jammy -COPY --from=build /pkg/hugegraph-loader/apache-hugegraph-loader-*/ /loader -WORKDIR /loader/ - RUN set -x \ && apt-get -q update \ && apt-get -q install -y --no-install-recommends --no-install-suggests \ @@ -45,6 +38,9 @@ RUN set -x \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* +COPY --from=build /pkg/hugegraph-loader/apache-hugegraph-loader-*/ /loader +WORKDIR /loader/ + VOLUME /loader ENTRYPOINT ["/usr/bin/dumb-init", "--"]