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

Entry Dockerfile is a duplicate but no duplicate handling strategy has been set #518

Open
pstobiecki-ocado opened this issue Jan 26, 2022 · 3 comments

Comments

@pstobiecki-ocado
Copy link

What happened?

With a Gradle configuration like this one:

docker {
    //  [...]

    dependsOn bootJar
    files bootJar.archivePath, fileTree('src/main/docker')
    dockerfile file('src/main/docker/Dockerfile')
    //  [...]
}

I'm getting the following error (with Gradle 7.3):

* What went wrong:
Execution failed for task ':edge:dockerPrepare'.
> Entry Dockerfile is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.3/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

because the Dockerfile wants to be copied twice - once as part of the files config and then as itself. Providing a correct duplicatesStrategy for dockerPrepare could solve it, but it's impossible to do it without modifying the plugin code.

What did you want to happen?

It would be great if:

  • the dockerPrepare task provided a duplicatesStrategy that allows such a build to pass, or
  • it was possible to configure a duplicatesStrategy for this task per build.

I worked around it by changing the Gradle config like this:

files bootJar.archivePath, fileTree('src/main/docker').matching { exclude 'Dockerfile' }

but I'd much prefer for it to work out of the box.

@stuartraetaylor
Copy link

This still seems to be an issue.

I'm working around it in a multi-module project like this,

In the root build.gradle:

subprojects {
    pluginManager.withPlugin('com.palantir.docker') {
        dockerPrepare {
            // Workaround for https://github.com/palantir/gradle-docker/issues/518
            duplicatesStrategy = DuplicatesStrategy.INCLUDE
        }
    }
}

@lucasmfraser
Copy link

@GeorgHoffmeyer
Copy link

I had a bit of the same issue. Problem is, that the dockerfile is in your src/main/docker folder. So it is first added with the files and than a second time with dockerfile

Solution 1:

Move Dockerfile to an other location than src/main/docker

Solution 2:

remove src/main/docker from files

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

4 participants