gradle-docker-plugin: inputDir not working

Hi,

i created the following gradle tasks to create a dockerfile and build a image from it:

task testBaseDockerfile(type: Dockerfile){
    ext.dockerImageName = 'test-base'
    destFile = project.file('./build/dockerfiles/' + ext.dockerImageName + '/Dockerfile')
    from(baseImage.dockerImageName + ":" + baseImage.dockerImageVersion)
    maintainer('me')
    addFile("./" , "/opt")
}

task testBaseImage(type: DockerBuildImage){
    dependsOn testBaseDockerfile
    inputDir = project.projectDir
    dockerFile = project.file('./build/dockerfiles/' + testBaseDockerfile.dockerImageName + '/Dockerfile')
    tag = testBaseDockerfile.dockerImageName + ':' + jar.version
}

I want to create a docker-image, that contains the whole project to run gradle tasks inside the docker-container. So i added the command addFile("./" , "/opt"). The problem is that only the files from ./build/dockerfiles/test-baseare added to the context and to the docker-image. The container, that is created from the dockerfile, has only following content:

root@7f3a7e5fe1ff:/opt# tree
.
└── build
    └── dockerfiles
        └── test-base
            └── Dockerfile

I also tried the current master with docker-java 2.2.3, but the problem is the same.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17

Most upvoted comments

You can specify a Dockerfile that is a) not called ‘Dockerfile’, and b) somewhere not at the root of the inputDir. But, due to restrictions on the way docker-java works, it must be contained within the inputDir subtree.

@cdancy

From dockers point of view, when it executes the Dockerfile, it’s looking at your ‘./’ and resolving that to the current directory.

It is not true, because @marbon87 set Docker build context dir explicitly via: inputDir = project.projectDir Note that in resulting image, there is directory tree with Dockerfile, so ./ was interpreted correctly, however other project files are missing.