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
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
It is not true, because @marbon87 set Docker build context dir explicitly via:
inputDir = project.projectDirNote that in resulting image, there is directory tree with Dockerfile, so./was interpreted correctly, however other project files are missing.