pascalgrimaud / generator-jhipster-docker

:whale: JHipster module, additional Docker support in your JHipster application
Apache License 2.0
58 stars 7 forks source link

java:openjdk-8-jdk-alpine doesn't work for automated build #27

Closed pascalgrimaud closed 6 years ago

pascalgrimaud commented 8 years ago

When I try to change the _Dockerfile and use java:openjdk-8-jdk-alpine instead of java:8, the build failed:

Here the stacktrace:

[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking /root/.m2/repository/com/github/eirslett/node/4.4.7/node-4.4.7-linux-x64.tar.gz into /code/node/tmp
[INFO] Copying node binary from /code/node/tmp/node-v4.4.7-linux-x64/bin/node to /code/node/node
[INFO] Installed node locally.
[INFO] Installing npm version 3.10.5
[INFO] Downloading http://registry.npmjs.org/npm/-/npm-3.10.5.tgz to /root/.m2/repository/com/github/eirslett/npm/3.10.5/npm-3.10.5.tar.gz
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking /root/.m2/repository/com/github/eirslett/npm/3.10.5/npm-3.10.5.tar.gz into /code/node/node_modules
[INFO] Installed npm locally.
[INFO] 
[INFO] --- frontend-maven-plugin:1.0:npm (npm install) @ jhipster-sample-application ---
[INFO] Running 'npm install' in /code
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 50.174 s
[INFO] Finished at: 2016-09-11T21:45:24+00:00
[INFO] Final Memory: 47M/471M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.0:npm (npm install) on project jhipster-sample-application: Failed to run task: 'npm install' failed. java.io.IOException: Cannot run program "/code/node/node" (in directory "/code"): error=2, No such file or directory -> [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/MojoFailureException
The command '/bin/sh -c echo '{ "allow_root": true }' > /root/.bowerrc &&     cd /code/ &&     ./mvnw clean package -Pprod -DskipTests &&     mv /code/target/*.war /app.war &&     rm -Rf /code &&     rm -Rf /root/.m2/wrapper &&     rm -Rf /root/.m2/repository &&     rm -Rf /root/.gradle &&     rm -Rf /home/jhipster/.npm/' returned a non-zero code: 1
The command "docker build -t jhipster-sample-app ." exited with 1.

Already reported here too: https://github.com/jhipster/jhipster-registry/issues/58#issuecomment-219657797

I'm stuck with this! Maybe @PierreBesson you have an idea ? I tried a lot of thing, but didn't manage to resolve it. I'm pretty sure it comes from alpine, something different between jessie image and alpine image...

PierreBesson commented 8 years ago

Of course it doesn't work because alpine doesn't play well with node. I had the same issue in the past and pretty much gave up hope to build the front-end in an alpine environment. Also we should migrate to the openjdk image as it seems "Java" is now deprecated https://hub.docker.com/_/java/ Did Oracle try to pressure docker ???

pascalgrimaud commented 8 years ago

Oh I didn't see this before, it's very recent: so I had to change my base image.

We have to change this, on the main generator too

pascalgrimaud commented 7 years ago

Currently, the image size is approximatively: ~358 MB It can be optimized by using alpine, but I'm fine with the current image. Closing this, as it can be improved later...

pascalgrimaud commented 7 years ago

Reading this https://docs.docker.com/engine/userguide/eng-image/multistage-build/ I'm pretty sure we can use openjdk:8-jre-alpine now!

PierreBesson commented 7 years ago

Multi stage build are now available in docker starting from v17.05. I just did a test (https://github.com/PierreBesson/jhipster-registry/commit/a9272c2c3055e7413a6903132b29d00f89603d17) and got the registry docker image from 735MB to 145MB ! Now we just have to wait for multistage to be supported by the docker hub.

pascalgrimaud commented 7 years ago

Yes I'm waiting this @PierreBesson ! https://docs.docker.com/engine/installation/#time-based-release-schedule

pascalgrimaud commented 7 years ago

@PierreBesson : I already tried it too :p

REPOSITORY                   TAG                 IMAGE ID            CREATED                  SIZE
jhipster/jhipster-registry   travis              0fc254bf9000        Less than a second ago   145MB
<none>                       <none>              9cf45903d86e        4 seconds ago            678MB
openjdk                      8-jre-alpine        58ce9579eac6        3 hours ago              81.4MB
openjdk                      8                   ab0ecda9094c        2 weeks ago              610MB
pascalgrimaud commented 6 years ago

Fix in this commit: https://github.com/pascalgrimaud/generator-jhipster-docker/commit/1584e335ae68d4d1e4f8c1ad15c1f96c5cc163ec