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

Building Docker Image with Gradle fails with “COPY failed: no source files were specified” #150

Open
arafatmohammed opened this issue Jan 25, 2019 · 2 comments

Comments

@arafatmohammed
Copy link

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.

@bjornmagnusson
Copy link
Contributor

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

@rud
Copy link

rud commented Jun 24, 2019

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/

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

3 participants