This is an automated email from the ASF dual-hosted git repository.
imbajin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hugegraph-toolchain.git
The following commit(s) were added to refs/heads/master by this push:
new 1b164c39 perf(docker): avoid emulated Java builds (#740)
1b164c39 is described below
commit 1b164c396a750f4a73825c131d1a8631a2cad3ae
Author: imbajin <[email protected]>
AuthorDate: Sun Jul 12 21:42:13 2026 +0800
perf(docker): avoid emulated Java builds (#740)
* 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
* 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
---
.dockerignore | 39 +++++++++++++++++++++++++++++++++++++++
README.md | 20 ++++++++++++++++++--
hugegraph-hubble/Dockerfile | 5 +++--
hugegraph-loader/Dockerfile | 16 ++++++----------
4 files changed, 66 insertions(+), 14 deletions(-)
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..af6405a3
--- /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/README.md b/README.md
index 322e6bda..7846c33f 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-hubble/Dockerfile b/hugegraph-hubble/Dockerfile
index 4591715d..97f72ed5 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/ \
diff --git a/hugegraph-loader/Dockerfile b/hugegraph-loader/Dockerfile
index 85f60929..0f68f4be 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", "--"]