Azure / draft-classic

A tool for developers to create cloud-native applications on Kubernetes.
https://draft.sh
MIT License
3.92k stars 395 forks source link

`docker build .` of a naked spring-boot web app fails when using the "alpine" version of the `maven:3.5-jdk-8` image #526

Closed cyrille-leclerc closed 6 years ago

cyrille-leclerc commented 6 years ago

Problem description

Naked spring-boot web application generated by start.spring.io fail in docker build . when using maven:3.5-jdk-8-alpine.

The failure is a crash of the jvm forked by Maven to run the unit tests

Workaround

Using the Docker image maven:3.5-jdk-8 (debian) instead of maven:3.5-jdk-8-alpine fixes the failure.

Dockerfile looks like:

FROM maven:3.5-jdk-8 as BUILD

COPY . /usr/src/app
RUN mvn --batch-mode -f /usr/src/app/pom.xml clean package

FROM openjdk:8-jdk-alpine
ENV PORT 4567
EXPOSE 4567
COPY --from=BUILD /usr/src/app/target/app-*.jar /opt/app.jar
WORKDIR /opt
CMD ["java", "-jar", "app.jar"]

Error message

See details https://gist.github.com/cyrille-leclerc/a08476fdb722a99b7f4def808e7b15a7

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.cloudbees.test.kubernetes.draft.DraftSpringBootAppSpringBootAppApplicationTests
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:30 min
[INFO] Finished at: 2018-01-31T14:19:48Z
[INFO] Final Memory: 30M/195M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test (default-test) on project draft-spring-boot-app: There are test failures.
[ERROR] 
[ERROR] Please refer to /usr/src/app/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /usr/src/app && /usr/lib/jvm/java-1.8-openjdk/jre/bin/java -jar /usr/src/app/target/surefire/surefirebooter7523040216371386228.jar /usr/src/app/target/surefire 2018-01-31T14-19-45_429-jvmRun1 surefire8802414022600742585tmp surefire_0149193590904832235tmp
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /usr/src/app && /usr/lib/jvm/java-1.8-openjdk/jre/bin/java -jar /usr/src/app/target/surefire/surefirebooter7523040216371386228.jar /usr/src/app/target/surefire 2018-01-31T14-19-45_429-jvmRun1 surefire8802414022600742585tmp surefire_0149193590904832235tmp
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:686)
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:535)
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:280)
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR]     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1124)
[ERROR]     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:954)
[ERROR]     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:832)
[ERROR]     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[ERROR]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
[ERROR]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
[ERROR]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
[ERROR]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR]     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
[ERROR]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR]     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
[ERROR]     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
[ERROR]     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
[ERROR]     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:955)
[ERROR]     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
[ERROR]     at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
[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 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR]     at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR]     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR]     at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[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 --batch-mode -f /usr/src/app/pom.xml clean package' returned a non-zero code: 1

To reproduce

git clone https://github.com/cloudbeers/draft-spring-boot-app.git
cd draft-spring-boot-app
git checkout a6e0968403e6ecaebffde20359156897240bee96
docker build .
cyrille-leclerc commented 6 years ago

I see that languages such as PHP use Docker images based on Debian instead of Alpine, I would be happy to propose a Pull Request to use Debian instead of Alpine if the Draft project is interested.

bacongobbler commented 6 years ago

Sure thing!

cyrille-leclerc commented 6 years ago

PR proposed: #531

prabdeb commented 6 years ago

I think still we can use alpine if we add RUN apk add --no-cache procps

Reference: https://issues.apache.org/jira/browse/SUREFIRE-1422