diff --git a/sovrn/Dockerfile b/sovrn/Dockerfile index f6e7ff0de50d..dc43d6416c06 100644 --- a/sovrn/Dockerfile +++ b/sovrn/Dockerfile @@ -11,8 +11,14 @@ RUN wget https://downloads.lightbend.com/scala/2.12.17/scala-2.12.17.tgz -P /tmp ln -s /usr/local/scala-2.12.17 /usr/local/scala && \ rm /tmp/scala-2.12.17.tgz -# Set environment variables for Java, Python, Maven, and Scala -ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto.aarch64 +# Set a default value for TARGET_PLATFORM +# This is chosen at build time using the --build-arg flag +# Example: docker build --build-arg TARGET_PLATFORM=aarch64 -t xgboost . +ARG TARGET_PLATFORM=aarch64 +#ARG TARGET_PLATFORM=x86_64 + +# Set environment variables for Java and Scala +ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto.${TARGET_PLATFORM} ENV PATH=${PATH}:${JAVA_HOME}/bin:/usr/local/scala/bin # Set Java 8 as the default Java version diff --git a/sovrn/README.md b/sovrn/README.md index aa4465c0e0d0..860e0b5f72f5 100644 --- a/sovrn/README.md +++ b/sovrn/README.md @@ -23,6 +23,15 @@ docker run -v $(pwd)/..:/xgboost --rm -it xgboost-build Now you should have a Docker ready to build your jar for aarch64/ARM64. +## Cross-Compile XGBoost for x86_64 on ARM64 + +```bash +docker buildx create --name xgboost-builder --use +docker buildx inspect --bootstrap +docker buildx build --platform linux/amd64 -t xgboost-build . --load --build-arg TARGET_PLATFORM=amd64 +docker run -v $(pwd)/..:/xgboost --rm -it --platform linux/amd64 xgboost-build +``` + # Inside the Docker ```bash