Skip to content

Commit 8995c97

Browse files
committed
Add Docker Native image building
1 parent cf09868 commit 8995c97

File tree

3 files changed

+57
-20
lines changed

3 files changed

+57
-20
lines changed

.mill-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.7-13-1803cb
1+
0.10.8

build.sc

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import com.goyeau.mill.scalafix.ScalafixModule
1010
import $ivy.`io.github.davidgregory084::mill-tpolecat::0.3.1`
1111
import io.github.davidgregory084.TpolecatModule
1212

13+
import $ivy.`com.carlosedp::mill-docker-nativeimage::0.1-SNAPSHOT`
14+
import com.carlosedp.milldockernative.DockerNative
15+
1316
object libVersion {
1417
val scala = "3.2.0"
1518
val scalajs = "1.11.0"
@@ -41,13 +44,47 @@ trait Common extends ScalaModule with TpolecatModule with ScalafmtModule with Sc
4144

4245
// object shared extends Common
4346

44-
object backend extends Common with DockerModule {
47+
object backend extends Common with DockerModule with DockerNative {
4548
// Runtime dependencies
4649
def ivyDeps = super.ivyDeps() ++ Agg(
4750
ivy"dev.zio::zio:${libVersion.zio}",
4851
ivy"io.d11::zhttp:${libVersion.zhttp}",
4952
)
5053

54+
object dockerNative extends DockerNativeConfig {
55+
def nativeImageName = "backend"
56+
def nativeImageGraalVmJvmId = T {
57+
sys.env.getOrElse("GRAALVM_ID", "graalvm-java17:22.2.0")
58+
}
59+
def nativeImageClassPath = runClasspath()
60+
def nativeImageMainClass = "com.carlosedp.zioscalajs.backend.MainApp"
61+
def nativeImageOptions = super.nativeImageOptions() ++ Seq(
62+
"--no-fallback",
63+
"--enable-url-protocols=http,https",
64+
"-Djdk.http.auth.tunneling.disabledSchemes=",
65+
// "--static", // Does not work on MacOS
66+
"--no-fallback",
67+
"--install-exit-handlers",
68+
"--enable-http",
69+
"--initialize-at-run-time=io.netty.channel.DefaultFileRegion",
70+
"--initialize-at-run-time=io.netty.channel.epoll.Native",
71+
"--initialize-at-run-time=io.netty.channel.epoll.Epoll",
72+
"--initialize-at-run-time=io.netty.channel.epoll.EpollEventLoop",
73+
"--initialize-at-run-time=io.netty.channel.epoll.EpollEventArray",
74+
"--initialize-at-run-time=io.netty.channel.kqueue.KQueue",
75+
"--initialize-at-run-time=io.netty.channel.kqueue.KQueueEventLoop",
76+
"--initialize-at-run-time=io.netty.channel.kqueue.KQueueEventArray",
77+
"--initialize-at-run-time=io.netty.channel.kqueue.Native",
78+
"--initialize-at-run-time=io.netty.channel.unix.Limits",
79+
"--initialize-at-run-time=io.netty.channel.unix.Errors",
80+
"--initialize-at-run-time=io.netty.channel.unix.IovArray",
81+
"--allow-incomplete-classpath",
82+
)
83+
84+
def tags = List("docker.io/carlosedp/zioscalajs-backend")
85+
def exposedPorts = Seq(8080)
86+
}
87+
5188
object docker extends DockerConfig {
5289
def tags = List("docker.io/carlosedp/zioscalajs-backend")
5390
def exposedPorts = Seq(8080)

package-lock.json

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)