forked from sbt/sbt-native-packager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support building Graal native images in docker
Closes sbt#1250 This provides support for building Graal native images in a docker container.
- Loading branch information
Showing
12 changed files
with
303 additions
and
29 deletions.
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
36 changes: 36 additions & 0 deletions
36
...main/scala/com/typesafe/sbt/packager/graalvm-native-image/GraalVMNativeImageBuilder.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,36 @@ | ||
package com.typesafe.sbt | ||
package packager | ||
package graalvmnativeimage | ||
|
||
/** | ||
* The builder for a GraalVM native image. | ||
*/ | ||
sealed trait GraalVMNativeImageBuilder | ||
|
||
object GraalVMNativeImageBuilder { | ||
|
||
/** | ||
* Base trait for builders that build the native image in docker | ||
*/ | ||
trait Docker extends GraalVMNativeImageBuilder | ||
|
||
private val GraalVMNativeImageCommand = "native-image" | ||
|
||
/** | ||
* Build locally using the given command. | ||
*/ | ||
final case class Local(command: String = GraalVMNativeImageCommand) extends GraalVMNativeImageBuilder | ||
|
||
/** | ||
* Build using a prepackaged Graal `native-image` container. The container must execute the Graal `native-image` | ||
* command with the arguments supplied to the container. | ||
*/ | ||
final case class PrepackagedDocker(image: String) extends Docker | ||
|
||
/** | ||
* Build using a generated Graal `native-image` container. This will build a Graal native-image container if not | ||
* already present in the local docker registry based on the supplied base image, which must provide a Graal | ||
* installation. | ||
*/ | ||
final case class GeneratedDocker(baseImage: String = GraalVMNativeImagePlugin.GraalVMBaseImage) extends Docker | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/sbt-test/graalvm-native-image/docker-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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
enablePlugins(GraalVMNativeImagePlugin) | ||
|
||
name := "docker-test" | ||
version := "0.1.0" | ||
graalVMNativeImageGraalVersion := Some("19.0.0") |
1 change: 1 addition & 0 deletions
1
src/sbt-test/graalvm-native-image/docker-native-image/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.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) |
5 changes: 5 additions & 0 deletions
5
src/sbt-test/graalvm-native-image/docker-native-image/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") | ||
} | ||
} |
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"' |
Oops, something went wrong.