0

i'm trying to deploy quarkus graalvm native image into google cloud run using by Dokerfile.

But always getting an error without any reasons, i think timeout exception occurs..

My Dockerfile:

## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/ubi-quarkus-native-image:21.3.0-java11 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:1.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", "-Dquarkus.http.port=8080"]

On time, I got error like:

Caused by: java.lang.RuntimeException: Image generation failed. Exit code was 137 which indicates an out of memory error. Consider increasing the Xmx value for native image generation by setting the "quarkus.native.native-image-xmx" property

And No error and deploy cutting like:

Downloaded from central: 

https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.3.2/junit-platform-launcher-1.3.2.jar (95 kB at 1.1 MB/s)
Step #0 - "Build": Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-engine/1.3.2/junit-platform-engine-1.3.2.jar (138 kB at 1.7 MB/s)
Step #0 - "Build": [INFO] 
Step #0 - "Build": [INFO] -------------------------------------------------------
Step #0 - "Build": [INFO]  T E S T S
Step #0 - "Build": [INFO] -------------------------------------------------------
Step #0 - "Build": [INFO] Running org.acme.GreetingResourceTest
Step #0 - "Build": 2022-01-13 16:56:17,402 INFO  [io.quarkus] (main) Quarkus 2.6.2.Final on JVM started in 8.961s. Listening on: http://localhost:8081
Step #0 - "Build": 2022-01-13 16:56:17,407 INFO  [io.quarkus] (main) Profile test activated. 
Step #0 - "Build": 2022-01-13 16:56:17,407 INFO  [io.quarkus] (main) Installed features: [cdi, google-cloud-firestore, kotlin, reactive-routes, resteasy, resteasy-jackson, security, smallrye-context-propagation, smallrye-jwt, vertx]
Step #0 - "Build": [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 17.027 s - in org.acme.GreetingResourceTest
Step #0 - "Build": 2022-01-13 16:56:20,521 INFO  [io.quarkus] (main) Quarkus stopped in 0.107s
Step #0 - "Build": [INFO] 
Step #0 - "Build": [INFO] Results:
Step #0 - "Build": [INFO] 
Step #0 - "Build": [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
Step #0 - "Build": [INFO] 
Step #0 - "Build": [INFO] 
Step #0 - "Build": [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ code-with-quarkus ---
Step #0 - "Build": [INFO] Building jar: /code/target/code-with-quarkus-1.0.0-SNAPSHOT.jar
Step #0 - "Build": [INFO] 
Step #0 - "Build": [INFO] --- quarkus-maven-plugin:2.6.2.Final:build (default) @ code-with-quarkus ---
Step #0 - "Build": [INFO] [org.jboss.threads] JBoss Threads version 3.4.2.Final
Step #0 - "Build": [INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /code/target/code-with-quarkus-1.0.0-SNAPSHOT-native-image-source-jar/code-with-quarkus-1.0.0-SNAPSHOT-runner.jar
Step #0 - "Build": [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /code/target/code-with-quarkus-1.0.0-SNAPSHOT-native-image-source-jar/code-with-quarkus-1.0.0-SNAPSHOT-runner.jar
Step #0 - "Build": [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM 21.3.0 Java 11 CE (Java Version 11.0.13+7-jvmci-21.3-b05)
Step #0 - "Build": [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] /opt/graalvm/bin/native-image -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 -H:-ParseOnce -J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -J-Djava.awt.headless=true -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https -H:NativeLinkerOption=-no-pie -H:-UseServiceLoaderFeature -H:+StackTrace code-with-quarkus-1.0.0-SNAPSHOT-runner -jar code-with-quarkus-1.0.0-SNAPSHOT-runner.jar
Step #0 - "Build": [code-with-quarkus-1.0.0-SNAPSHOT-runner:272]    classlist:  18,659.29 ms,  1.66 GB
Step #0 - "Build": [code-with-quarkus-1.0.0-SNAPSHOT-runner:272]        (cap):   1,132.47 ms,  1.66 GB
Step #0 - "Build": [code-with-quarkus-1.0.0-SNAPSHOT-runner:272]        setup:   6,444.03 ms,  1.66 GB
Step #0 - "Build": The bundle named: messages, has not been found. If the bundle is part of a module, verify the bundle name is a fully qualified class name. Otherwise verify the bundle path is accessible in the classpath.
Step #0 - "Build": 16:58:40,548 INFO  [org.jbo.threads] JBoss Threads version 3.4.2.Final
Step #0 - "Build": [code-with-quarkus-1.0.0-SNAPSHOT-runner:272]     (clinit):   2,996.64 ms,  1.94 GB
Step #0 - "Build": [code-with-quarkus-1.0.0-SNAPSHOT-runner:272]   (typeflow):  23,549.43 ms,  1.94 GB
Step #0 - "Build": [code-with-quarkus-1.0.0-SNAPSHOT-runner:272]    (objects): 314,587.70 ms,  1.94 GB
Step #0 - "Build": [code-with-quarkus-1.0.0-SNAPSHOT-runner:272]   (features):  22,672.94 ms,  1.94 GB
Step #0 - "Build": [code-with-quarkus-1.0.0-SNAPSHOT-runner:272]     analysis: 370,217.38 ms,  1.94 GB
Step #0 - "Build": [code-with-quarkus-1.0.0-SNAPSHOT-runner:272]     universe:  12,968.06 ms,  1.94 GB

Dockerfile occurs an error in my local:

#15 259.1 [ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.6.2.Final:build (default) on project code-with-quarkus: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
#15 259.1 [ERROR]       [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image
#15 259.1 [ERROR] Caused by: java.lang.RuntimeException: Image generation failed. Exit code was 137 which indicates an out of memory error. Consider increasing the Xmx value for native image generation by setting the "quarkus.native.native-image-xmx" property

Now i'm really thinking my Dockerfile is not correct.

Do you have any suggestions ? Thx

ytech
  • 157
  • 1
  • 10
  • 1
    Are you able to build your container on your workstation? The problem doesn't come from Cloud Run, it comes from your container creation! – guillaume blaquiere Jan 13 '22 at 20:40
  • 1
    When I start to deploy, cloud run create an image and containerized for me. what kind of problem do you think? – ytech Jan 13 '22 at 20:49
  • 1
    First Cloud Run gcloud command call Cloud Build for you to build your container. Then, when the container is built, Cloud Run deploy it on Cloud Run service. Here the Cloud Build process fail. Your container packaging doesn't work. I don't know why, but it's the focus here. You can use Docker locally, or Cloud Build directly to speed up your debug process. – guillaume blaquiere Jan 13 '22 at 20:51
  • 1
    normally i'm creating cloud run service using "Continuously deploy new revisions from a source repository" and Build type Dockerfile. I have a spring boot application and it's running. But when i'm trying service with quarkus native image there is a problem but still cannot find – ytech Jan 13 '22 at 20:55
  • 1
    Yes, I agree. I also use continuous deployment. But in that case, before setting the continuous deployment, the container creation has to be fixed. Then, it will be only configuration! – guillaume blaquiere Jan 13 '22 at 21:02
  • 1
    Yes maybe my Dockerfile is not correct, let's wait anybody comment about it, thx a lot @guillaumeblaquiere – ytech Jan 13 '22 at 21:04

0 Answers0