I'm trying to create a GraalVM native image with Dockers. I have created a Micronaut project, and successfully create a jar application and running this inside a docker; also I've created a GraalVM native image with this jar file and now is possible to run this application, but I need to run a graalvm native image inside a docker, looking for answers in forums I found that it is necessary to build the native image inside the docker, so I have tried with this Dockerfile:
# use graalvm image
# replace the occurences of "product" with you jar name
FROM openjdk:8u171-alpine3.7
# expose your port, 8080 fo Micronaut applicatoin
EXPOSE 8080
# copy the fat jar
COPY build/libs/*-all.jar products.jar
# create the reflection configuration file generated by Micronaut
# for other frameworks you need to construct the file yourself
ADD . build
#RUN java -cp products.jar io.micronaut.graal.reflect.GraalClassLoadingAnalyzer
# run the native image compiler, you should already know the command arguments
# if you're not running micronaut
ENV PATH=PATHTOGRAALVM/graalvm-ce-java8-20.3.0/bin:$PATH
ENV JAVA_HOME=PATHTOGRAALVM/graalvm-ce-java8-20.3.0
CMD native-image --no-server \
--class-path products.jar \
-H:ReflectionConfigurationFiles=build/reflect.json \
-H:EnableURLProtocols=http \
-H:IncludeResources="logback.xml|application.yml|META-INF/services/*.*" \
-H:Name=products \
-H:Class=products.Application \
-H:+ReportUnsupportedElementsAtRuntime \
-H:+AllowVMInspection \
--rerun-class-initialization-at-runtime='sun.security.jca.JCAUtil$CachedSecureRandomHolder,javax.net.ssl.SSLContext' \
--delay-class-initialization-to-runtime=io.netty.handler.codec.http.HttpObjectEncoder,io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder,io.netty.handler.ssl.util.ThreadLocalInsecureRandom
# the native command will be used to run the application
CMD ./products
And it doesn't throw any exception or something, so I tried to run my docker with this:
docker build --tag="products-with-graavm" .
docker run -d -p 8080:8080 products-with-graavm
But it does nothing, my app is not running, Is something wrong with my Dockerfile or I need to add other configuration to create my native image? Thanks.