debuglevel / greeting-microservice

Micronaut microservice template written in Kotlin
The Unlicense
5 stars 2 forks source link

native-image #5

Open debuglevel opened 3 years ago

debuglevel commented 3 years ago

Branch feature-graalvm tries to make this template work with native-image. But unclear if it's worth the effort (especially as further dependencies could easily break the whole thing)

debuglevel commented 2 years ago

master includes a gradle target nativeCompile which works. feature-graalvm additionally includes an adapted Dockerfile.

debuglevel commented 2 years ago

liquibase stuff does not work yet. /edit maybe see https://build-native-java-apps.cc/native-image/resources/

debuglevel commented 2 years ago

Current feature-graalvm Dockerfile should work (tested on github actions). But merging master failed with

#23 62.21 Error: Classes that should be initialized at run time got initialized during image building:
#23 62.21  kotlin.jvm.internal.Reflection was unintentionally initialized at build time. To see why kotlin.jvm.internal.Reflection got initialized use --trace-class-initialization=kotlin.jvm.internal.Reflection
#23 62.21 kotlin.KotlinVersion was unintentionally initialized at build time. To see why kotlin.KotlinVersion got initialized use --trace-class-initialization=kotlin.KotlinVersion

Maybe update each dependency on their own to find out what was causing it.

debuglevel commented 2 years ago

IIRC, the problem is somewhere in LogstashEncoder

diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index c0f15a5..5114e27 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -39,8 +39,8 @@
     </appender>

     <!-- Logs in JSON, which can be useful in combination with e.g. Elasticstack -->
-    <!-- <appender name="json-stdout" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder class="net.logstash.logback.encoder.LogstashEncoder"> -->
+    <appender name="json-stdout" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="net.logstash.logback.encoder.LogstashEncoder">
             <!-- Slows down logging but includes where the logging was called from -->
             <!-- <includeCallerData>true</includeCallerData> -->

@@ -48,12 +48,12 @@
             <!-- <customFields>{"appname":"myWebservice","roles":["customerorder","auth"],"buildinfo":{"version":"Version 0.1.0-SNAPSHOT","lastcommit":"75473700d5befa953c45f630c6d9105413c16fe1"}}</customFields> -->

             <!-- Pretty print JSON as it should not hurt performance but easens debugging -->
-            <!-- <jsonGeneratorDecorator class="net.logstash.logback.decorate.PrettyPrintingJsonGeneratorDecorator"/> -->
+            <jsonGeneratorDecorator class="net.logstash.logback.decorate.PrettyPrintingJsonGeneratorDecorator"/>

             <!-- Timestamp is already in ISO-8601, so no customization should be needed. -->
             <!-- <timestampPattern>yyyy-MM-dd'T'HH:mm:ss.SSS</timestampPattern> -->
-    <!--    </encoder>
-    </appender> -->
+        </encoder>
+    </appender>

     <root level="info">
         <!-- Use the appender defined by the environment variable LOG_APPENDER or use a default -->
debuglevel commented 2 years ago

Maybe use --no-parallel as it might reduce memory usage? /edit: nevermind, that is a gradle option.