我正在尝试按照此文档(https://ballerina.io/learn/build-a-native-executable)使用 GraalVM 本机映像编译器构建 Ballerina 应用程序,并在 docker 映像期间收到以下错误构建阶段。
错误:
> [build 4/4] RUN sh build-native.sh my_service.jar my_service:
#0 3.676 WARNING: Unknown module: org.graalvm.nativeimage.llvm specified to --add-exports
#0 3.678 WARNING: Unknown module: org.graalvm.nativeimage.llvm specified to --add-exports
#0 3.680 WARNING: Unknown module: org.graalvm.nativeimage.llvm specified to --add-exports
#0 59.74 ========================================================================================================================
#0 59.74 GraalVM Native Image: Generating 'my_service' (executable)...
#0 59.76 ========================================================================================================================
#0 75.84 Error: Image build request failed with exit status 137
------
ERROR: failed to solve: executor failed running [/bin/sh -c sh build-native.sh my_service.jar my_service]: exit code: 137
error [k8s plugin]: module [wso2/my_service:0.1.0] docker build failed. refer to the build log
warning: Detected conflicting jar files:
'ballerina-rt-2201.4.0.jar' dependency of 'wso2/my_service' conflict with 'opentelemetry-api-1.0.0.jar' dependency of 'ballerinax/jaeger'
环境信息:
JDK:11.0.18(arm64)“Eclipse Adoptium”-“OpenJDK 11.0.18”
GraalVM:graalvm-ce-java11-darwin-aarch64-22.3.1
退出代码 137 表明内存不足问题。 增加分配给 docker 的内存可以解决该问题。 由于 GraalVM 构建会消耗大量内存,因此建议至少为 docker 分配 8GB 内存。 (参考docker build的前提条件)