Building an open source Scala gRPC/REST HTTP Proxy for Kafka (II)
Day 1 of the journey on building my first Scala GraalVM ZIO application
Continued from Day 0
Day 1: Getting builds under control
Now that we have a basic project setup and somewhat building, we need to stabilise it a bit more, so we can spend all our future energy on actually writing the code. This means CI/CD, dockerising, versioning, but more important getting the binary stable on *nix and mac environments. This means diving deeper into GraalVM and it’s available build tools. So far we (the native packager) only used the
native-imagetool from graal, but we need a way to start defining the scala/java reflections via the
Fortunately reflections are not encouraged in Scala and many libraries have few, but few is not the same as none.
Local & remote
As we’ve seen we can build the native image locally (on mac) if we do all these prerequisite steps, but I just discovered this awesome sbt library,
sbt-native-image, that basically does everything for you, downloading all binaries using coursier, without needing to install & run graal and subsequent tools project local. This would have saved me a lot of time, but the code is not wasted. The biggest strength is also the biggest drawback of this library. It does everything for you, but leaves you with little control over the end product, especially if the goal is dockerising the end product.
So for now the approach is twofold, and why not. We keep both the
sbt-native-image plugins and use each of their strengths.
We do define some basic graalvm settings that can be used by both approaches. I don’t know if we’ll keep all these settings as is, but for now it works
val jvmVersion = "11"
val graalVersion = "220.127.116.11"
val baseGraalOptions = Seq(