-
Notifications
You must be signed in to change notification settings - Fork 444
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
Support building Graal native images in docker #1251
Conversation
d7bdc01
to
8d6ce5c
Compare
@jroper, as you've said in #1250, there's a benefit in making the docker/native split feature somewhat reusable. I agree that there's not much hope here for reusing implementation. However, we should strive to at least make the API predictable. val sourceDockerImage = taskKey[Option[String]]("Coordinates for a docker image to use in a command") This is intended to specify an image for use in an arbitrary command. E.g. in the case of the GraalVMNativeImage / packageBin / sourceDockerImage := {
// build an image, or provide coordinates for an existing one
}
GraalVMNativeImage / packageBin := {
val sourceDockerImage0 := (GraalVMNativeImage / packageBin / sourceDockerImage).value
// ...
sourceDockerImage0 match {
case None =>
buildLocal(...)
case Some(image) =>
buildInDockerContainer(... , image, ...)
}
} This way we can provide a consistent API between plugins. Of course, there's room for improvement. One thing that comes to mind is that there might be commands that only support Docker execution, in which case a |
I'm not a big fan of logic based on whether something's defined or not, it's a bit magic. |
Updated. I called the setting |
c8bc77e
to
36687d8
Compare
src/main/scala/com/typesafe/sbt/packager/graalvmnativeimage/GraalVMNativeImagePlugin.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/typesafe/sbt/packager/graalvmnativeimage/GraalVMNativeImagePlugin.scala
Show resolved
Hide resolved
008e9fb
to
b6a5303
Compare
Closes sbt#1250 This provides support for building Graal native images in a docker container.
Something I've encountered while using this in a real project, I want to limit the amount of memory that |
Using this on a real project, I'm starting to think going with depending on |
Sorry for my late reply. Thanks for tackling this issue 🤗 The general idea looks good to me. IMHO making this reusable shouldn't be a big focus. RPM and Debian are stable since years with rather less complaints/issues. On the other hand docker changes rather frequently and it's hard to keep up with those changes. Long story short: If there's a user willing to contribute a "docker-rpm build", then a shared API as @nigredo-tori suggested is the maximum we should do.
We already have If this seems to error prone we could introduce something like |
I retriggered all builds as there seem to be major issues on all CI vendors -.- |
Thanks @jroper for the implementation ❤️ |
@jroper this was not done, i.e use |
Yeah, I should have backed out that change (I did in my local copy of the plugin). |
@jtjeferreira or @jroper would you like to open a pull request to fix this? |
Closes #1250
This provides support for building Graal native images in a docker container.
The simplest way to enable the docker container build is to set:
When setting this, the plugin will generate a docker image based on
oracle/graalvm-ce:19.1.1
which installs thenative-image
command. It will then run this image to build the Graal native image. Options are provided to customise which base image the generated image uses, along with allowing it to use a prepackaged image rather than generating one.The graal plugin has been restructured a little to be more idiomatic for sbt. I also introduced a dependency on the
JavaAppPackaging
plugin, because a graal vm image in this case is a java app, and this allows us to use thescriptClasspathOrdering
, so configuring it and the behaviour of the classpath is consistent with the rest of native packager.I also moved the setting of the
dockerExecCommand
setting from theDockerPlugin
to theUniversalPlugin
, this means that any native packager plugin that depends onUniversalPlugin
can use that setting without having to depend onDockerPlugin
.