Transmode / gradle-docker

A Gradle plugin to build Docker images from the build script.
Apache License 2.0
647 stars 142 forks source link

image creation hangs indefinitely #119

Open digitalkram opened 7 years ago

digitalkram commented 7 years ago

Hello,

I am trying to build a docker image with gradle v3.5.1 (Windows 10, docker 1.12.3 (8488), IntelliJ) of my spring boot v1.5.5.RELEASE application.

Excerpt from my build.gradle:

buildscript {
    ext {
        springBootVersion = "1.5.5.RELEASE"
    }
    repositories {
        mavenCentral()
        maven { url "http://repo.spring.io/plugins-release" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath("se.transmode.gradle:gradle-docker:1.2")
        classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5")
        classpath("io.spring.gradle:propdeps-plugin:0.0.9.RELEASE")
    }
}
apply plugin: "java"
apply plugin: "idea"
apply plugin: "org.springframework.boot"
apply plugin: "docker"
apply plugin: "org.sonarqube"
apply plugin: "propdeps"
[...]
task buildDocker(type: Docker, dependsOn: build) {
    baseImage = "develar/java:latest"
    push = project.hasProperty("push")
    volume "/tmp"
    entryPoint(["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/app.jar"])
    exposePort(8080)
    addFile {
        from jar
        rename { "app.jar" }
    }
}
[...]

Sadly it hangs indefinitely here when executing task buildDocker:

[...]
:build
:buildDocker
      [tar] Building tar: C:\path\to\intellij_workspace\projectname\build\docker\add_4.tar
[...]

The tar it self is properly built but the subsequent call of native "docker build [...]" seems to hang.

Some more info is available when running "gradlew clean buildDocker --info":

[...]
Executing task ':buildDocker' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
Setting up staging directory.
Creating tar archive C:\path\to\intellij_workspace\projectname\build\docker\add_4.tar from C:\Users\USRNAM~1\AppData\Local\Temp\1504257706294-0
      [tar] Building tar: C:\path\to\intellij_workspace\projectname\build\docker\add_4.tar
Creating Dockerfile from base develar/java:latest.
Determining image tag: module-name:0.0.2-SNAPSHOT
Using the native docker binary.
<============-> 93% EXECUTING
> :buildDocker
> IDLE
> IDLE
> IDLE

[...]

Fun fact no. 1: When I abort the gradle build, rerun und abort again I have a fully functional docker images in my local docker. Fun fact no. 2: When I run the command that the pluin executes (found out by stoping docker while build was running and extracted from resulting error message - failed to run command [command]) in a shell it runs flawlessly:

docker build -t module-name:0.0.2-SNAPSHOT C:\path\to\intellij_workspace\projectname\build\docker
Sending build context to Docker daemon 48.34 MB
Step 1 : FROM develar/java:latest
 ---> edc8788ce767
Step 2 : VOLUME /tmp
 ---> Using cache
 ---> b54c4358382c
Step 3 : ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
 ---> Using cache
 ---> 0f914d908edf
Step 4 : EXPOSE 8080
 ---> Using cache
 ---> 8d01e6df662b
Step 5 : ADD add_4.tar /
 ---> e3905be0616c
Removing intermediate container b58d8e4ad8c9
Successfully built e3905be0616c

I am currently a bit out of ideas why the external command execution hangs. Any hint would by highly appreciated! Thanks a lot in advance! Let me know in case that you need more information.

digitalkram commented 7 years ago

Just realized that this probably duplicates #37. There seems to be a pr to fix it pending for roughly three years.