Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'files' parameters is verified too early for a dynamically generated Docker context #97

Closed
GJKrupa opened this issue Jan 13, 2017 · 5 comments

Comments

@GJKrupa
Copy link

GJKrupa commented Jan 13, 2017

I'm trying to create a Docker context that only includes the output TAR from the distribution plugin so I've configured it as...

docker {
    dependsOn distTar
    name "${project.group}/${project.name}:${project.version}"
    tags "latest"
    buildArgs([BUILD_VERSION: project.version])
    files distTar.archivePath.absolutePath, 'Dockerfile'
}

This configuration is failing, however, because the Docker plugin is checking for the existence of this file during project configuration, long before it get created.

This isn't a huge issue but without specifying the 'files' parameter, the entire src/ directory plus build.gradle, gradle.properties etc. are also getting copied unnecessarily into the context.

@uschi2000
Copy link
Contributor

Hej! Can you try removing the "files" parameter, please? See this test as an example: https://github.com/palantir/gradle-docker/pull/93/files#diff-42ea40a578e12c8725a6379907334c76R462

@GJKrupa
Copy link
Author

GJKrupa commented Jan 14, 2017

Hi, as stated above (I added it in a later edit do you may not have seen it) the build works if I remove the 'files' parameter but copies a lot of unnecessary files into the context. In general, though, it would be a lot more powerful if it could be used specify derived as well as source files.

@uschi2000
Copy link
Contributor

Ah, I didn't read your initial comment carefully enough, sorry. I agree that the current interaction of the dependsOn/files parameters is a bit unfortunate. The plugin functionality grew organically and the addition of the files parameter made things messy. I think we can revisit the behavior next time we break the API. Do you have a recommendation?

@GJKrupa
Copy link
Author

GJKrupa commented Jan 15, 2017

Might be sufficient to use the 'archivePath' property of the dependsOn task if it exists to define the context and then fall back to the existing behaviour if it's not available. This property is exposed for, at the very least, the application, distribution, ear, war and jar plugins.

IMO the files parameter is useful should be able to handle 2 possible types of values:

  • A mixed list of File and String (and GString) objects
  • A closure that returns the above and is evaluated as late as possible

A couple of "nice to have" features would be a flag to indicate whether to flatten or maintain the directory structure and the ability to use Ant-style wildcards (but that then introduces the need for exclusion lists which gets even more messy).

@uschi2000
Copy link
Contributor

uschi2000 commented Jan 18, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants