-
Notifications
You must be signed in to change notification settings - Fork 442
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
Adds cross platform architecture compilation for native image #1549
Open
kgston
wants to merge
17
commits into
sbt:main
Choose a base branch
from
kgston:multiarch-native-image
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
415f641
Adds cross platform architecture compilation for native image
kgston a6c701e
scalafmt
kgston 47b847c
Update to use graalvm/setup-graalvm
kgston d352378
Update docs
kgston ebcdb21
Support new graalvm container versions, backwards support for legacy …
kgston 4e45cc0
Add support for native-image images, revert to use entrypoint
kgston 46d044d
Update docs
kgston 8db7495
Attempt to fix binary compatibility
kgston 5928aa8
sbt cross build version attempt
kgston b4fa76d
Add docker buildx to github action
kgston 16fea55
Fix architecture label
kgston b48618f
Ignore bsp
kgston bb0faad
fmt
kgston 3161c3c
Fix buildx docker image not found
kgston 5cc6b9b
Add QEMU to github action
kgston c197795
Retain docker build compat if not using graalVMNativeImagePlatformArch
kgston 4532720
Update documentation
kgston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=1.5.4 | ||
sbt.version=1.9.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/sbt-test/graalvm-native-image/docker-native-image-arm64/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
enablePlugins(GraalVMNativeImagePlugin) | ||
|
||
name := "docker-test" | ||
version := "0.1.0" | ||
graalVMNativeImageOptions := Seq("--no-fallback") | ||
graalVMNativeImageGraalVersion := Some("graalvm-community:17.0.8") | ||
graalVMNativeImagePlatformArch := Some("arm64") |
1 change: 1 addition & 0 deletions
1
src/sbt-test/graalvm-native-image/docker-native-image-arm64/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % sys.props("project.version")) |
5 changes: 5 additions & 0 deletions
5
src/sbt-test/graalvm-native-image/docker-native-image-arm64/src/main/scala/Main.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
object Main { | ||
def main(args: Array[String]): Unit = { | ||
println("Hello Graal") | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/sbt-test/graalvm-native-image/docker-native-image-arm64/test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Generate the GraalVM native image | ||
> show graalvm-native-image:packageBin | ||
$ exec bash -c 'docker run --rm --platform arm64 -v .:/test -w /test ubuntu ./target/graalvm-native-image/docker-test | grep -q "Hello Graal"' |
6 changes: 6 additions & 0 deletions
6
src/sbt-test/graalvm-native-image/docker-native-image-legacy-specify-package/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
enablePlugins(GraalVMNativeImagePlugin) | ||
|
||
name := "docker-test" | ||
version := "0.1.0" | ||
graalVMNativeImageOptions := Seq("--no-fallback") | ||
graalVMNativeImageGraalVersion := Some("graalvm-ce:22.3.3") |
1 change: 1 addition & 0 deletions
1
...-test/graalvm-native-image/docker-native-image-legacy-specify-package/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % sys.props("project.version")) |
5 changes: 5 additions & 0 deletions
5
...graalvm-native-image/docker-native-image-legacy-specify-package/src/main/scala/Main.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
object Main { | ||
def main(args: Array[String]): Unit = { | ||
println("Hello Graal") | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/sbt-test/graalvm-native-image/docker-native-image-legacy-specify-package/test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Generate the GraalVM native image | ||
> show graalvm-native-image:packageBin | ||
$ exec bash -c 'target/graalvm-native-image/docker-test | grep -q "Hello Graal"' |
6 changes: 6 additions & 0 deletions
6
src/sbt-test/graalvm-native-image/docker-native-image-legacy/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
enablePlugins(GraalVMNativeImagePlugin) | ||
|
||
name := "docker-test" | ||
version := "0.1.0" | ||
graalVMNativeImageOptions := Seq("--no-fallback") | ||
graalVMNativeImageGraalVersion := Some("22.3.3") |
1 change: 1 addition & 0 deletions
1
src/sbt-test/graalvm-native-image/docker-native-image-legacy/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % sys.props("project.version")) |
5 changes: 5 additions & 0 deletions
5
src/sbt-test/graalvm-native-image/docker-native-image-legacy/src/main/scala/Main.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
object Main { | ||
def main(args: Array[String]): Unit = { | ||
println("Hello Graal") | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/sbt-test/graalvm-native-image/docker-native-image-legacy/test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Generate the GraalVM native image | ||
> show graalvm-native-image:packageBin | ||
$ exec bash -c 'target/graalvm-native-image/docker-test | grep -q "Hello Graal"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/sbt-test/graalvm-native-image/simple-native-image/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
enablePlugins(GraalVMNativeImagePlugin) | ||
|
||
name := "simple-test" | ||
|
||
version := "0.1.0" | ||
graalVMNativeImageOptions := Seq("--no-fallback") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will never get the difference in my head. Why is this change from entrypoint to cmd needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the difference between
ENTRYPOINT
andCMD
is that the former predetermines the executable that will run in the docker container while the latter just sets it as the default, but allows you to override it at runtime.I gave it a bit more thought and looked at the available options again and I found a way to return to using
ENTRYPOINT
instead.Originally, the reason why I used
CMD
is because in the latest GraalVM images that Oracle provides, bundles thenative-image
executable out of the box by default, so there is no longer any real need to create a custom docker image that installs thenative-image
executable. Instead, we can just directly use the docker image provided by Oracle. However, in order to keep thedocker run
command consistent between both the Oracle provided image and the legacy native-packager generated image, I changed the legacy image to useCMD
instead ofENTRYPOINT
.But on more research, it seems like there are 2 versions of the image that we can use.
graalvm-community
is a generic version that usesCMD
and allows you to choose your executable, and anative-image-community
specialized one that usesENTRYPOINT
. I tweaked the code such that we can support both images while keeping the previous style of usingENTRYPOINT
as the entry to the docker image.