spotify / docker-maven-plugin

INACTIVE: A maven plugin for Docker
Apache License 2.0
2.67k stars 575 forks source link

gitlab ci dose not work with docker maven plugin #372

Closed azizkhani closed 6 years ago

azizkhani commented 6 years ago

I want build docker image in gitlab ci but i got this exception

Software:

Full backtrace

[INFO] Building Docker context /builds/vahed98-monolithic/smart-gateway/target
[INFO] 
[INFO] Image will be built as vahed98-gateway:latest
[INFO] 
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: No such file or directory
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: No such file or directory
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: No such file or directory
Feb 18, 2018 2:38:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:11 min
[INFO] Finished at: 2018-02-18T14:38:37+00:00
[INFO] Final Memory: 54M/200M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.4:build (default-cli) on project vahed98Front: Could not build image: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.io.IOException: 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/MojoExecutionException
ERROR: Job failed: exit code 1
leandroBorgesFerreira commented 6 years ago

Hello @azizkhami. Could you provide your gitlab configuration? I believe you are not using dind

azizkhani commented 6 years ago

I dont know why not work?

image: openjdk:8-jdk-alpine

services:
  - docker:dind

deploy:
  stage: test
  script:
    - './mvnw clean package -DskipTests=true dockerfile:build '
  only:
    - master
leandroBorgesFerreira commented 6 years ago

I believe you need to set the variables the docker host variable: variables: DOCKER_HOST: tcp://docker:2375/

azizkhani commented 6 years ago

in .gitlab-ci.yml file?

leandroBorgesFerreira commented 6 years ago

Yes. Like this:

image: openjdk:8-jdk-alpine

services:
  - docker:dind
variables:
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_DRIVER: overlay2

deploy:
  stage: test
  script:
    - './mvnw clean package -DskipTests=true dockerfile:build '
  only:
    - master
leandroBorgesFerreira commented 6 years ago

@azizkhani Did this solution work for you?

azizkhani commented 6 years ago

no


Downloaded: https://repo.maven.apache.org/maven2/com/spotify/docker-client/8.8.1/docker-client-8.8.1-shaded.jar (7.4 MB at 3.3 MB/s)
[INFO] Using Google application default credentials
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.747 s
[INFO] Finished at: 2018-02-19T17:46:55Z
[INFO] Final Memory: 42M/101M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.4:build (default-cli) on project vahed98Front: Execution default-cli of goal com.spotify:dockerfile-maven-plugin:1.3.4:build failed: Unparseable port number: docker:2375/ -> [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/PluginExecutionException
ERROR: Job failed: exit code 1
leandroBorgesFerreira commented 6 years ago

Uhm... it looks like you have a different problem now. But I don't know what may be causing this =/. Maybe some maintainer of this library can help you

azizkhani commented 6 years ago

yes it works fine 👍

leandroBorgesFerreira commented 6 years ago

@azizkhani Could your provide your solution to make your build work?

azizkhani commented 6 years ago

change to DOCKER_HOST: tcp://docker:2375

wnloaded: https://repo.maven.apache.org/maven2/com/spotify/docker-client/8.8.1/docker-client-8.8.1-shaded.jar (7.4 MB at 3.3 MB/s)
[INFO] Using Google application default credentials
[INFO] Building Docker context /builds/vahed98-monolithic/smart-gateway/target
[INFO] 
[INFO] Image will be built as vahed98-gateway:latest
[INFO] 
[INFO] Step 1/5 : FROM openjdk:8-jre-alpine
[INFO] 
[INFO] Pulling from library/openjdk
[INFO] Image ff3a5c916c92: Pulling fs layer
[INFO] Image 5de5f69f42d7: Pulling fs layer
[INFO] Image fa7536dd895a: Pulling fs layer
[INFO] Image 5de5f69f42d7: Downloading
[INFO] Image 5de5f69f42d7: Verifying Checksum
[INFO] Image 5de5f69f42d7: Download complete
[INFO] Image ff3a5c916c92: Downloading
[INFO] Image fa7536dd895a: Downloading
[INFO] Image ff3a5c916c92: Verifying Checksum
[INFO] Image ff3a5c916c92: Download complete
[INFO] Image ff3a5c916c92: Extracting
[INFO] Image ff3a5c916c92: Pull complete
[INFO] Image 5de5f69f42d7: Extracting
[INFO] Image 5de5f69f42d7: Pull complete
[INFO] Image fa7536dd895a: Verifying Checksum
[INFO] Image fa7536dd895a: Download complete
[INFO] Image fa7536dd895a: Extracting
[INFO] Image fa7536dd895a: Pull complete
[INFO] Digest: sha256:d3468b0fab294db03b4a67cabdaccf9c47a635ad14429ad43a0cce522e1ca8b3
[INFO] Status: Downloaded newer image for openjdk:8-jre-alpine
[INFO]  ---> b1bd879ca9b3
[INFO] Step 2/5 : ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS     JHIPSTER_SLEEP=0     JAVA_OPTS=""
[INFO] 
[INFO]  ---> Running in 4b9ab9c155e2
[INFO] Removing intermediate container 4b9ab9c155e2
[INFO]  ---> 867c723ec09f
[INFO] Step 3/5 : ADD *.war /app.war
[INFO] 
[INFO]  ---> 52605187dab7
[INFO] Step 4/5 : EXPOSE 80
[INFO] 
[INFO]  ---> Running in bacbecb3084a
[INFO] Removing intermediate container bacbecb3084a
[INFO]  ---> 7fa426cbf314
[INFO] Step 5/5 : CMD echo "The application will start in ${JHIPSTER_SLEEP}s..." &&     sleep ${JHIPSTER_SLEEP} &&     java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /app.war
[INFO] 
[INFO]  ---> Running in e4e555d27fbb
[INFO] Removing intermediate container e4e555d27fbb
[INFO]  ---> 3a150089a779
[INFO] Successfully built 3a150089a779
[INFO] Successfully tagged vahed98-gateway:latest
[INFO] 
[INFO] Detected build of image with id 3a150089a779
[INFO] Building jar: /builds/vahed98-monolithic/smart-gateway/target/app-docker-info.jar
[INFO] Successfully built vahed98-gateway:latest
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:05 min
[INFO] Finished at: 2018-02-19T17:51:27Z
[INFO] Final Memory: 44M/106M
[INFO] ------------------------------------------------------------------------
section_end:1519062688:build_script
section_start:1519062688:after_script
section_end:1519062690:after_script
section_start:1519062690:archive_cache
section_end:1519062691:archive_cache
section_start:1519062691:upload_artifacts
section_end:1519062693:upload_artifacts
Job succeeded

leandroBorgesFerreira commented 6 years ago

But did you do any change in the .gitlab-ci.yml file that I provided you? What's is your final version?

azizkhani commented 6 years ago

yes remove / like this DOCKER_HOST: tcp://docker:2375

leandroBorgesFerreira commented 6 years ago

Oh, I see. Thanks =]

naikaa commented 5 years ago

or in the config.toml mount the volumes like this volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]

mikhail-putilov commented 4 years ago

If anybody encounters the same problem and finds this answer in google, instead of making blind guesses, better take a look at those two links, they are helpful and provide more value than the accepted answer: (Second block of code) https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-disabled https://docs.gitlab.com/runner/executors/kubernetes.html#using-dockerdind

chaitanya003 commented 4 years ago

Could you share the link to your GITLAB project