Transmode / gradle-docker

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

buildDocker error: Invalid repository name #66

Open Dreampie opened 8 years ago

Dreampie commented 8 years ago

registry=http://192.168.60.41:5000

* What went wrong:
Execution failed for task ':eureka-server:buildDocker'.
> Docker execution failed
  Command line [docker build -t http://192.168.60.41:5000/eureka-server:1.0-SNAPSHOT /Users/Dreampie/Projects/DreampieProjects/cloud-server/eureka-server/build/docker] returned:
  Invalid repository name (ex: "registry.domain.tld/myrepos")

registry=192.168.60.41:5000

* What went wrong:
Execution failed for task ':eureka-server:buildDocker'.
> Docker execution failed
  Command line [docker push 192.168.60.41:5000/eureka-server:1.0-SNAPSHOT] returned:
  unable to ping registry endpoint https://192.168.60.41:5000/v0/
  v2 ping attempt failed with error: Get https://192.168.60.41:5000/v2/: EOF
   v1 ping attempt failed with error: Get https://192.168.60.41:5000/v1/_ping: EOF

docker-registry in http not https

bjornmagnusson commented 8 years ago

Please add some more information to ease understanding of your setup, such as your distDocker config in build.gradle.

Dreampie commented 8 years ago
task buildDocker(type: Docker, dependsOn: build) {
  maintainer = "Dreampie <Dreampie@outlook.com>"
  push = true
  applicationName = jar.baseName
  dockerfile = file("src/main/docker/Dockerfile")
  registry = dockerRegistry
  doFirst {
    copy {
      from jar
      into stageDir
    }
  }
}

My registry in http://192.168.60.41:5000,but docker use https://192.168.60.41:5000

 docker-machine create --driver virtualbox --engine-insecure-registry 192.168.60.41:5000 dev

set insecure-registry must create new virtualbox,could not update?

alethenorio commented 8 years ago

I have run into the same problem when trying the plugin for the same time. Interestingly enough I am also trying to build an Eureka Server

In my case I have a multi-parent project where the folder structure is the following

ParentFolder
      |
      |___ build.gradle
      |___ eurekaServer
                   |____ build.gradle

My parent build.gradle contains the following plugin configuration

allprojects {

    group = "com.mycompany"
    version = "1.0.0-SNAPSHOT"

    task wrapper(type: Wrapper) {
        gradleVersion = '2.11'
        distributionUrl = 'http://services.gradle.org/distributions/gradle-2.11-all.zip'
    }
}
subprojects {

    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'idea'
    apply plugin: 'spring-boot'
    apply plugin: "io.spring.dependency-management"
    apply plugin: 'docker'

    repositories {
        mavenCentral()
    }

    dependencyManagement {
        imports {
            mavenBom 'org.springframework.cloud:spring-cloud-starter-parent:Angel.SR6'
        }
    }

    dependencies {
        compile('org.springframework.cloud:spring-cloud-starter-config')
        testCompile('org.springframework.boot:spring-boot-starter-test')
    }

    docker {
        baseImage "java:8"
    }

    task buildDocker(type: Docker, dependsOn: build) {
        push = false
        applicationName = jar.baseName
        volume "/tmp"
        addFile {
            from jar
            rename {'app.jar'}
        }
        runCommand "bash -c 'touch /app.jar'"
        entryPoint(['java', '-Djava.security.egd=file:/dev/./urandom', '-jar', '/app.jar'])
    }
}

And the eurekaServer build.gradle is setup this way

jar {
    baseName = 'eurekaserver'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile('org.springframework.cloud:spring-cloud-starter-eureka-server')
    testCompile('org.springframework.boot:spring-boot-starter-test') 
}

Now here is the interesting part. I actually have a few more children applications under the parentFolder and they build without any problems but the eureka server does not and spits out the following error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':eurekaServer:buildDocker'.
> Docker execution failed
  Command line [docker build -t com.mycompany/eurekaServer:1.0.0-SNAPSHOT /some/folder/eurekaServer/build/docker] returned:
  invalid value "com.mycompany/eurekaServer:1.0.0-SNAPSHOT" for flag -t: Error parsing reference: "com.mycompany/eurekaServer:1.0.0-SNAPSHOT" is not a valid repository/tag
  See 'docker build --help'.

Notice that for some reason it is using the folder name which has came case (eurekaServer) instead of the actual configured applicationName in the parent which is set to jar.basename and the jar baseName is not camel case (eurekaserver).

My other children projects which build without any errors do not have camel case so to test I changed one of their folder names to came case and sure enough I got the same error there as well. The plugin seems to be ignoring the applicationname setting in the parent

Could this be the same issue at play here or should I maybe open up a new issue?