Reputation: 4559
I'm trying to deploy a native build of a Quarkus application to Render.com, but it fails. The build seems to run fine, as far as I can tell, but the application won't run. I can't reproduce it on my local setup.
My build is derived from Quarkus's proposal of a multistage build. For future reference if the link changes, this boils down to using this Dockerfile:
## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:22.3-java17 AS build
COPY --chown=quarkus:quarkus mvnw /code/mvnw
COPY --chown=quarkus:quarkus .mvn /code/.mvn
COPY --chown=quarkus:quarkus pom.xml /code/
USER quarkus
WORKDIR /code
RUN ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline
COPY src /code/src
RUN ./mvnw package -Pnative
## Stage 2 : create the docker final image
FROM quay.io/quarkus/quarkus-micro-image:2.0
WORKDIR /work/
COPY --from=build /code/target/*-runner /work/application
# set up permissions for user `1001`
RUN chmod 775 /work /work/application \
&& chown -R 1001 /work \
&& chmod -R "g+rwX" /work \
&& chown -R 1001:root /work
EXPOSE 8080
USER 1001
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
This Dockerfile basically creates two images:
The second one is what you obtain at the end of your Docker build.
I just do a 2-step test:
docker build . -t my-app
docker run --rm -p 8080:8080 -it my-app
It works perfectly fine.
All the building steps of the Docker image run fine, I get to the final "BUILD SUCCESS" message in the logs, and then Render seems to publish the image, and start to run it.
Only, it just outputs an error that I have no idea how to debug. I cannot reproduce locally (nor on Windows, nor on Linux), I haven't found a way of downloading Render's image and compare it with my own. In the stack trace, there are mentions of code that has been generated by the build, so I cannot see that either.
ERROR: Failed to start application (with profile [prod])
java.lang.NullPointerException
at [email protected]/java.util.Objects.requireNonNull(Objects.java:208)
at [email protected]/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:263)
at [email protected]/java.nio.file.Path.of(Path.java:147)
at [email protected]/java.nio.file.Paths.get(Paths.java:69)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.CgroupUtil.lambda$readStringValue$0(CgroupUtil.java:57)
at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:144)
at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:569)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.CgroupUtil.readStringValue(CgroupUtil.java:59)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.CgroupSubsystemController.getStringValue(CgroupSubsystemController.java:66)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.CgroupSubsystemController.getLongValue(CgroupSubsystemController.java:125)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.cgroupv1.CgroupV1Subsystem.getLongValue(CgroupV1Subsystem.java:269)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.cgroupv1.CgroupV1Subsystem.getHierarchical(CgroupV1Subsystem.java:215)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.cgroupv1.CgroupV1Subsystem.setSubSystemControllerPath(CgroupV1Subsystem.java:203)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.cgroupv1.CgroupV1Subsystem.initSubSystem(CgroupV1Subsystem.java:111)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.cgroupv1.CgroupV1Subsystem.<clinit>(CgroupV1Subsystem.java:47)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.CgroupSubsystemFactory.create(CgroupSubsystemFactory.java:78)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.CgroupMetrics.getInstance(CgroupMetrics.java:164)
at [email protected]/java.lang.reflect.Method.invoke(Method.java:568)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.Metrics.systemMetrics(Metrics.java:63)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.containers.Container.metrics(Container.java:44)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.ContainerInfo.<init>(ContainerInfo.java:34)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.Containers.activeProcessorCount(Containers.java:125)
at [email protected]/java.lang.Runtime.availableProcessors(Runtime.java:247)
at org.wildfly.common.cpu.ProcessorInfo.availableProcessors(ProcessorInfo.java:29)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder.calculateDefaultIOThreads(VertxCoreRecorder.java:394)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder.calculateEventLoopThreads(VertxCoreRecorder.java:518)
at io.quarkus.deployment.steps.VertxCoreProcessor$eventLoopCount1012482323.deploy_0(Unknown Source)
at io.quarkus.deployment.steps.VertxCoreProcessor$eventLoopCount1012482323.deploy(Unknown Source)
at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
at io.quarkus.runtime.Application.start(Application.java:101)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:108)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)
I tweaked that Dockerfile a little to build and deploy a Java app instead, and it works, but I feel I'm really close to having the native version working, so I'd like to do the final push if possible.
I'm not expecting someone to come with a definite solution, my problem seems far too specific to me, but any input that might help me understand the error is welcome:
Upvotes: 2
Views: 525
Reputation: 805
As per my previous comments, it looks like something changed in the last few hours on Render side that triggered this GraalVM open bug. The only workaround I can think of is to put aside the Quarkus native build for now, and revert to a JVM build. The following Dockerfile should do the trick.
## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:22.3-java17 AS build
COPY --chown=quarkus:quarkus mvnw /code/mvnw
COPY --chown=quarkus:quarkus .mvn /code/.mvn
COPY --chown=quarkus:quarkus pom.xml /code/
USER quarkus
WORKDIR /code
RUN ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline
COPY src /code/src
RUN ./mvnw package
## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi8/openjdk-17:1.14
WORKDIR /work/
COPY --from=build --chown=185 /code/target/quarkus-app/lib/ /deployments/lib/
COPY --from=build --chown=185 /code/target/quarkus-app/*.jar /deployments/
COPY --from=build --chown=185 /code/target/quarkus-app/app/ /deployments/app/
COPY --from=build --chown=185 /code/target/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8080
USER 185
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
Upvotes: 1