gradle-docker icon indicating copy to clipboard operation
gradle-docker copied to clipboard

Docker build context (build/docker dir)

Open mashimom opened this issue 9 years ago • 5 comments

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

mashimom avatar Oct 27 '16 13:10 mashimom

Can you provide a minimal repo (or maybe just test case) that shows the error?

uschi2000 avatar Oct 27 '16 15:10 uschi2000

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).

evmin avatar Oct 29 '16 11:10 evmin

@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.

evmin avatar Oct 30 '16 06:10 evmin

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.

snwiem avatar May 18 '17 20:05 snwiem

What is "MoveTo"?

uschi2000 avatar May 18 '17 20:05 uschi2000