Docker build context (build/docker dir)
I may be miss-using the plugin, please let me know if that is the case.
I configured a new project according to examples, what I observe is that entire project (minus build/) is copied to build/docker. I causes an unnecessary large docker build context.
Is there a way to prevent that?
Inspecting source I see it was not supposed to to copy everything when ext.resolvedFiles has value.
Thanks
Can you provide a minimal repo (or maybe just test case) that shows the error?
Got the same issue - build/docker contains the whole project after running "gradle docker". There is no error per - se. It is just that the folder is huge and building it takes time (copying files over).
@mashimom
I think I have found a workaround. I am overriding another docker step - dockerPrepare - preparing the 'build/docker' folder explicitly. I need only a single fatJar in addition to the Dockerfile.
task dockerCopy(type: MoveTo, dependsOn: dockerPrepare) {
from('build/packed') {
include "${jarFullName}"
}
into 'build/docker'
}
docker {
name "${dockerImageName}"
dockerfile 'src/main/docker/Dockerfile'
files 'src/main/docker/Dockerfile'
}
By explicitly setting "files" in docker section I avoid copying everything else. And the custom dockerPrepare step copies over the required file.
Hope that helps.
task dockerCopy(type: MoveTo, dependsOn: dockerPrepare) {
from('build/libs') {
include "*.jar"
}
into "build/docker"
}
results in
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\snwiem\Projects\cloud-app\cloud-discovery\build.gradle' line: 48
* What went wrong:
A problem occurred evaluating project ':cloud-discovery'.
> Could not get unknown property 'MoveTo' for project ':cloud-discovery' of type org.gradle.api.Project.
What is "MoveTo"?