quarkusio / quarkus-quickstarts

Quarkus quickstart code
https://quarkus.io
Apache License 2.0
1.95k stars 1.46k forks source link

Native multistage docker buid fails for spring-data-jpa-quickstart #396

Closed Hollerweger closed 4 years ago

Hollerweger commented 4 years ago

Here my added docker multistage file to 1.0.1.Final spring-data-jpa-quickstart:

## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/centos-quarkus-maven:19.2.1 AS build
COPY src /usr/src/app/src
COPY pom.xml /usr/src/app
USER root
RUN chown -R quarkus /usr/src/app
USER quarkus
RUN mvn -f /usr/src/app/pom.xml -Pnative -DskipTests=true clean package

## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /work/
COPY --from=build /usr/src/app/target/*-runner /work/application
RUN chmod 775 /work
EXPOSE 8080
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

Docker build command: docker build -f src/main/docker/Dockerfile.multistage -t quarkus-spring-data-jpa-quickstart .\

Exception:

[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /usr/src/app/target/spring-data-jpa-quickstart-1.0-SNAPSHOT-native-image-source-jar/spring-data-jpa-quickstart-1.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /usr/src/app/target/spring-data-jpa-quickstart-1.0-SNAPSHOT-native-image-source-jar/spring-data-jpa-quickstart-1.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on OpenJDK 64-Bit GraalVM CE 19.2.1
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] /opt/graalvm/bin/native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-DCoordinatorEnvironmentBean.transact
ionStatusManagerEnable=false -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.maxO
rder=1 --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -jar spring-data-jpa-quickstart-1.0-SNAPSHOT-runner.jar -J-Djava.util.concurrent.ForkJoinPool.common.para
llelism=1 -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https --enable-all-security-services -H:+JNI --no-server -H:-UseServiceLoaderFeature -H:+StackTrace spring-data-jpa-quick
start-1.0-SNAPSHOT-runner
[spring-data-jpa-quickstart-1.0-SNAPSHOT-runner:170]    classlist:  14,891.43 ms
[spring-data-jpa-quickstart-1.0-SNAPSHOT-runner:170]        (cap):   1,343.84 ms
[spring-data-jpa-quickstart-1.0-SNAPSHOT-runner:170]        setup:   3,383.15 ms
21:40:58,780 INFO  [org.hib.Version] HHH000412: Hibernate Core {5.4.9.Final}
21:40:58,825 INFO  [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
21:40:58,924 INFO  [org.hib.dia.Dialect] HHH000400: Using dialect: io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL95Dialect
21:41:01,853 INFO  [org.jbo.threads] JBoss Threads version 3.0.0.Final
Error: Image build request failed with exit status 137
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:08 min
[INFO] Finished at: 2019-12-08T21:42:21Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.0.1.Final:native-image (default) on project spring-data-jpa-quickstart: Failed to generate a native image: Failed to augment application classes: Build failure: Build
 failed due to errors
[ERROR]         [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:289)
[ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
[ERROR]         at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
[ERROR]         at java.lang.Thread.run(Thread.java:748)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] Caused by: java.lang.RuntimeException: Image generation failed
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:278)
[ERROR]         ... 12 more
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
The command '/bin/sh -c mvn -f /usr/src/app/pom.xml -Pnative -DskipTests=true clean package' returned a non-zero code: 1
gsmet commented 4 years ago

Exit code 137 means not enough memory to build the native image.

On Sun, Dec 8, 2019 at 10:56 PM Martin notifications@github.com wrote:

Here my added docker multistage file to 1.0.1.Final spring-data-jpa-quickstart:

Stage 1 : build with maven builder image with native capabilities

FROM quay.io/quarkus/centos-quarkus-maven:19.2.1 AS build COPY src /usr/src/app/src COPY pom.xml /usr/src/app USER root RUN chown -R quarkus /usr/src/app USER quarkus RUN mvn -f /usr/src/app/pom.xml -Pnative -DskipTests=true clean package

Stage 2 : create the docker final image

FROM registry.access.redhat.com/ubi8/ubi-minimal WORKDIR /work/ COPY --from=build /usr/src/app/target/*-runner /work/application RUN chmod 775 /work EXPOSE 8080 CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

Docker build command: docker build -f src/main/docker/Dockerfile.multistage -t quarkus-spring-data-jpa-quickstart .\

Exception:

[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /usr/src/app/target/spring-data-jpa-quickstart-1.0-SNAPSHOT-native-image-source-jar/spring-data-jpa-quickstart-1.0-SNAPSHOT-runner.jar [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /usr/src/app/target/spring-data-jpa-quickstart-1.0-SNAPSHOT-native-image-source-jar/spring-data-jpa-quickstart-1.0-SNAPSHOT-runner.jar [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on OpenJDK 64-Bit GraalVM CE 19.2.1 [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] /opt/graalvm/bin/native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-DCoordinatorEnvironmentBean.transact ionStatusManagerEnable=false -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.maxO rder=1 --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -jar spring-data-jpa-quickstart-1.0-SNAPSHOT-runner.jar -J-Djava.util.concurrent.ForkJoinPool.common.para llelism=1 -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https --enable-all-security-services -H:+JNI --no-server -H:-UseServiceLoaderFeature -H:+StackTrace spring-data-jpa-quick start-1.0-SNAPSHOT-runner [spring-data-jpa-quickstart-1.0-SNAPSHOT-runner:170] classlist: 14,891.43 ms [spring-data-jpa-quickstart-1.0-SNAPSHOT-runner:170] (cap): 1,343.84 ms [spring-data-jpa-quickstart-1.0-SNAPSHOT-runner:170] setup: 3,383.15 ms 21:40:58,780 INFO [org.hib.Version] HHH000412: Hibernate Core {5.4.9.Final} 21:40:58,825 INFO [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.0.Final} 21:40:58,924 INFO [org.hib.dia.Dialect] HHH000400: Using dialect: io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL95Dialect 21:41:01,853 INFO [org.jbo.threads] JBoss Threads version 3.0.0.Final Error: Image build request failed with exit status 137 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 03:08 min [INFO] Finished at: 2019-12-08T21:42:21Z [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.0.1.Final:native-image (default) on project spring-data-jpa-quickstart: Failed to generate a native image: Failed to augment application classes: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:289) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.lang.reflect.Method.invoke(Method.java:498) [ERROR] at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:415) [ERROR] at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) [ERROR] at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426) [ERROR] at java.lang.Thread.run(Thread.java:748) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:479) [ERROR] Caused by: java.lang.RuntimeException: Image generation failed [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:278) [ERROR] ... 12 more [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException The command '/bin/sh -c mvn -f /usr/src/app/pom.xml -Pnative -DskipTests=true clean package' returned a non-zero code: 1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/quarkusio/quarkus-quickstarts/issues/396?email_source=notifications&email_token=AAJYOBIPP42UNNTVK4VPEILQXVURBA5CNFSM4JYAX472YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H65PO6Q, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJYOBOJ36O7RBH6H3DNUELQXVURBANCNFSM4JYAX47Q .

Hollerweger commented 4 years ago

@gsmet Thanks for the quick response! Overlooked this error. Build works after increasing the memory for docker engine.