Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to building native image for ARM #1443

Open
ghost opened this issue Aug 5, 2021 · 5 comments · May be fixed by #1549
Open

How to building native image for ARM #1443

ghost opened this issue Aug 5, 2021 · 5 comments · May be fixed by #1549
Labels

Comments

@ghost
Copy link

ghost commented Aug 5, 2021

I would like to build GraalVM native image for ARM architecture from my AMD machine.
It such feature currently supported by native-packager ?

As for now I have tried to use docker image with hash in GraalVMNativeImagePlugin.generateContainerBuildImage() what should allow me to pull ARM based docker image.

Ex:
GraalVMNativeImagePlugin.generateContainerBuildImage("ghcr.io/graalvm/graalvm-ce:latest@sha256:94a029ea80df5d66e5f49d30a1a4348b654e2cb8ccc7a26ec209691943a2ee8e")

Unfortunately it results in error Error response from daemon: build tag cannot contain a digest

Information

  • What sbt-native-packager are you using -> 1.8.1
  • What sbt version -> 1.5.2
  • What is your build system -> MacOs AMD64
  • What package are you building -> docker
  • What version has your build tool -> set
  • What is your target system -> any with ARM base CPU
@f0o
Copy link

f0o commented Nov 25, 2021

@muuki88
Is there any news regarding this? We might be facing a similar issue where we want to provide multi-arch Docker Images

@muuki88
Copy link
Contributor

muuki88 commented Nov 25, 2021

I'm happy to help you with implementing this feature😊, but I don't have the time nor the experience or setup to build this 😃

@dswiecki
Copy link
Contributor

@muuki88 Can you describe the steps needed to implement this feature here ? It looks as if there need to extend FROM directive with platform parameter but you are probably aware of other places that should be changed ;)

@muuki88
Copy link
Contributor

muuki88 commented Dec 14, 2021

I have no real experience with graal + docker and especially not ARM 😅

However the concept for all formats in native packager is always the same

  1. Layout the files on disc as required for the packaging tool ( e.g. Docker / stage puts all files along with a Dockerfile in the target/docker folder
  2. Execute the packaging command with the desired parameters

Step 1 should already be available, so it's only part 2. I'll check later what SBT tasks and settings are available.

What would the packaging command look like?

@kyri-petrou
Copy link

I'm not an expert on GraalVM's native-image, but from what I understand is that the resulting executable is both OS and CPU architecture specific. I've been able to build linux/arm64 binaries successfully using this setting on my ARM64 Macbook: graalVMNativeImageGraalVersion := Some("22.0.0.2"). I can then containerise the native-image using a Dockerfile such as:

FROM oraclelinux:8-slim
COPY ./target/graal-native-image/my-application ./app/

CMD ./app/my-application

Assuming my understanding is correct of how native-image builds work, if you want to build a macos/arm64 binary instead that you can run locally and not in a container, you're out of luck until there is a macos/arm64 version of GraalVM/native-image. You can keep an eye out for new GraalVM releases here, and look out for something tagged darwin-aarch64-XXXX.tar.gz

I hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants