使用Gradle构建Docker映像失败,并显示“复制失败:未指定源文件”

时间:2019-01-25 04:51:13

标签: gradle build.gradle dockerfile gradle-plugin gradlew

我是Gradle的新手。我正在尝试从我的 build.gradle

中构建一个Dockerfile。

Dockerfile

Sub passport_combining()

    Dim wsheet As Worksheet

    For Each wsheet In ThisWorkbook.Sheets
            If wsheet.Name <> "MainSheet" Then

                Set nextEntry_FTE_quantity = Cells(Rows.Count, "K").End(xlUp).Offset(1, 0)
                Set nextEntry_nonrecurring_expenses = Cells(Rows.Count, "S").End(xlUp).Offset(1, 0)
                Set nextEntry_initiative_type = Cells(Rows.Count, "Q").End(xlUp).Offset(1, 0)
                Set nextEntry = Cells(Rows.Count, "G").End(xlUp).Offset(1, 0)

                If IsError(Application.Match(wsheet.Name, Range("G:G"), 0)) Then
                    nextEntry.Value = wsheet.Name
                    nextEntry_FTE_quantity.Value = wsheet.Range("BH16").Value
                    nextEntry_initiative_type.Value = wsheet.Range("K8").Value
                    nextEntry_nonrecurring_expenses.Value = wsheet.Range("BH17").Value
                End If

            End If
            Debug.Print wsheet.Name
    Next wsheet


End Sub

build.gradle

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/

输出

./ gradlew clean build buildDocker --info

  

任务':buildDocker'的执行失败。   Docker执行失败     命令行[docker build -t 73299472920.dkr.ecr.us-east-1.amazonaws.com/camunda:0.0.0.uncommitted-71119c2 / Users / amx / Code / backend / jclaim / build / docker]返回:< / p>      

复制失败:未指定源文件

我能够使用 docker build -t 从相同的 Dockerfile 手动构建该映像,但是在Gradle buildDocker任务中它以某种方式失败。

当我不添加最后两个 COPY

时,它甚至可以工作

Dockerfile

    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
            }
        }
    }

但是我也必须复制其他两个工件。

我的Docker Docker插件:

  

se.transmode.gradle:gradle-docker:1.2

Gradle版本:

  

5.1.1级

请帮助我解决此问题。

1 个答案:

答案 0 :(得分:0)

谢谢大家,我上班了。

我必须添加:

doFirst {
    copy {
        from war
        into stageDir
    }
       copy {
           from "${projectDir}/camunda/"
           into stageDir
       }
       copy {
           from "${projectDir}/definitions/"
           into stageDir
       }
}

在我的 build.gradle 中。这会将我所有的工件复制到build/docker/中,然后我的Dockerfile只需要它们COPY src dest中的文件名而不是COPY /path/to/src/ dest

此问题已解决。

谢谢大家!