gradle-docker
gradle-docker copied to clipboard
Building Docker Image with Gradle fails with “COPY failed: no source files were specified”
I am new to Gradle. I am trying to build a Dockerfile from within my build.gradle
Dockerfile
FROM camunda/camunda-bpm-platform:tomcat-7.7.0
COPY build/libs/*.war /camunda/webapps/
COPY camunda/ /camunda/webapps/engine-rest/WEB-INF/
COPY definitions/ /camunda/definitions/
build.gradle
task buildDocker(type: Docker, dependsOn: build) {
push = false
dockerfile = file("Dockerfile")
version release.version
tag = "${docker_registry_url}/camunda"
doFirst {
copy {
from war
into stageDir
}
copy {
from "${projectDir}/camunda/"
into stageDir
}
copy {
from "${projectDir}/definitions/"
into stageDir
}
}
}
Output
./gradlew clean build buildDocker --info
Execution failed for task ':buildDocker'. Docker execution failed Command line [docker build -t 73299472920.dkr.ecr.us-east-1.amazonaws.com/camunda:0.0.0.uncommitted-71119c2 /Users/amx/Code/backend/jclaim/build/docker] returned:
COPY failed: no source files were specified
I am able to build this image manually from the same Dockerfile using docker build -t but somehow it fails in Gradle buildDocker task.
It even works when I do not add the last two COPY
Dockerfile
FROM camunda/camunda-bpm-platform:tomcat-7.7.0
COPY build/libs/*.war /camunda/webapps/
But I have to COPY the other two artifacts as well.
My Docker plugin for Docker:
se.transmode.gradle:gradle-docker:1.2
Gradle Version:
Gradle 5.1.1
Please help me fix this.
Best guess is that the files you are trying to copy is not available at the time the docker command is executed. Take a look at the build/docker folder (docker build command is ran using this folder). Perhaps you can perform the copy closures in a separate tasks the the buildDocker task depend on. Might work
The plugin uses a "staging dir" which is then the directory the docker command is run within. So the cause for the error you see is that the current work directory is not what you expect.
COPY build/libs/*.war /camunda/webapps/
Should simply be:
COPY *.war /camunda/webapps/