-
Notifications
You must be signed in to change notification settings - Fork 142
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
addFile with generated directory doesn't work as expected #122
Comments
Can you provide an complete example gradle buildscript that demonstrates this? |
I have the same problem with him and here's my script. My script is to build docker image ( task buildDocker(type: Docker, dependsOn: 'ngBuild') {
// some config for tagname, push to repo, ...
// Copy nginx server config
addFile "${project.projectDir}/nginx/default.conf", '/etc/nginx/conf.d/'
// Remove old content
runCommand 'rm -rf /usr/share/nginx/html/*'
// Copy new content from `dist` folder (generate by task ngBuild)
addFile "${project.projectDir}/dist", '/usr/share/nginx/html/'
defaultCommand(['nginx', '-g', 'daemon off;'])
} I can confirmed that the
More information to identify the problem. |
Same issue here. |
We do welcome pull requests, so if any of you got on solution on your hand please provide it. |
We've been getting some of the same behavior but I think I have a workaround. Instead of using the gradle /build directory to reference resources in the addFile command. Use a direct reference to the src location. But realize that this removes any resource filtering capability in your build system; Doesn't work: Works: Background: In our java/gradle project we have a /src/main/resources/public directory that we add. When there is no /build directory (after a Gradle Task (broken state)
Source public directory contents:
Run On first run of
/build/docker contains ;
The second run of
Notice that the public directory is now included. So somewhere in the addFile command, when it copies resources to /build/docker, it fails to create the subdirectory |
Looking at this, it appears it's because the task is evaluating the contents of the build/ directory when gradle is executed, not when the task is executed. So if the subdirectory exists BEFORE gralde is invoked, it works correctly. |
Environment
Using version 1.2 of the gradle-docker plugin
Issue descripton
It seems that addFile must be used with a directory that exists before executing the gradle build.
I'm using addFile with a source directory generated under build:
The build fails with the following message:
Note that if the build/public directory exists when invoking gradle, it works.
Using "gradle clean build" does not impact this.
I.e, if build/public exists and one invokes "gradle clean build" it still works.
The issue arises only when doing a build from scratch (build/ directory does not exist).
I can workaround this issue by pre-creating the build/public directory before invoking gradle.
i.e
Is the use-case of addFile with a generated directory supported ?
After some troubleshooting I found out that the logic that defines the copy instructions for the staging directory is done early, before the build/public directory is generated.
See the following snippet from https://github.com/Transmode/gradle-docker/blob/master/src/main/groovy/se/transmode/gradle/plugins/docker/image/Dockerfile.groovy:
The copy doesn't fail, and instead of copying build/public into build/docker/public, it did copy build/public/* build/docker/, however the ADD statement in the generated docker file references a public directory that doesn't exist, and so the build fails.
The text was updated successfully, but these errors were encountered: