Last active
November 23, 2022 14:21
-
-
Save azolotko/bc642cd868c631038f690cacc2750b99 to your computer and use it in GitHub Desktop.
Generating a scratch-based container image with a GraalVM static native-image binary (via sbt-native-packager's GraalVMNativeImagePlugin and DockerPlugin)
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
enablePlugins( | |
GraalVMNativeImagePlugin, | |
DockerPlugin | |
) | |
GraalVMNativeImage / containerBuildImage := Some("ghcr.io/graalvm/native-image") | |
GraalVMNativeImage / graalVMNativeImageOptions += "--static" | |
GraalVMNativeImage / packageBin := (GraalVMNativeImage / packageBin).map { f => | |
scala.sys.process.Process(Seq("chmod", "u+x", f.absolutePath)).!!; f | |
}.value | |
dockerExecCommand := Seq("podman") // for those who use podman | |
dockerBaseImage := "scratch" | |
dockerPermissionStrategy := com.typesafe.sbt.packager.docker.DockerPermissionStrategy.None | |
Docker / daemonUserUid := None | |
dockerCommands := dockerCommands.value.filter { | |
case com.typesafe.sbt.packager.docker.Cmd("USER", _*) => false | |
case _ => true | |
} | |
Docker / mappings := Seq( | |
(GraalVMNativeImage / packageBin).value -> | |
(Docker / dockerEntrypoint).value.head | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment