简体   繁体   English

Gradle docker 构建无限期挂起

[英]Gradle docker build hangs indefinitely

My build works randomly and hangs randomly even when run with exactly the same parameters.即使使用完全相同的参数运行,我的构建也会随机运行并随机挂起。 It's always getting stuck after my copy task (some parts replaced with )我的复制任务后总是卡住(某些部分替换为 )

task createDocker(group: '<placeholder>', type: Docker) {
    push = true
    dockerfile = file(stageDir.getAbsolutePath()+"/Dockerfile")
    project.group = "<placeholder>"
    applicationName = "<placeholder>-clusterservice"
    tagVersion = "${project.version}"

    doFirst {
        println ("Copying Dockerfile to staging area:" + stageDir.getAbsolutePath())
        copy {
            from "${project.projectDir}/src/main/docker/"
            include "**/*"
            into stageDir
        }

        println ("Getting artifact")
        copy {
            from "$distDir/${war.baseName}-${war.version}.war"
            rename "${war.baseName}-${war.version}.war", "clusterservice.war"
            into stageDir
        }
    }
}

I ran it with debug flags and this is what it looks like when it works:我用调试标志运行它,这是它工作时的样子:

[16:26:15] :     [Step 1/1] 16:25:49.730 [QUIET] [system.out] Getting artifact
[16:26:15] :     [Step 1/1] 16:25:50.041 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Execute doFirst {} action for :clusterservice:createDocker'
[16:26:15] :     [Step 1/1] 16:25:50.041 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute doFirst {} action for :clusterservice:createDocker' completed
[16:26:15] :     [Step 1/1] 16:25:50.041 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute build for :clusterservice:createDocker' started
[16:26:15] :     [Step 1/1] 16:25:50.041 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Setting up staging directory.
[16:26:15] :     [Step 1/1] 16:25:50.041 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Creating Dockerfile from file /opt/teamcity/agent/work/7fe8da50bfc4c49f/clusterservice/build-gradle/docker/Dockerfile.
[16:26:15] :     [Step 1/1] 16:25:50.045 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Determining image tag: <placeholder>/<placeholder>-clusterservice:8.23.0-SNAPSHOT
[16:26:15] :     [Step 1/1] 16:25:50.045 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Using the native docker binary.
[16:26:15] :     [Step 1/1] 16:26:05.213 [QUIET] [system.out] Sending build context to Docker daemon    194MB
[16:26:15] :     [Step 1/1] 16:26:05.213 [QUIET] [system.out] Step 1/33 : FROM <placeholder>/tomcat-openjre8:8.5.40
[16:26:15] :     [Step 1/1] 16:26:05.213 [QUIET] [system.out]  ---> aa259d3bf785
[16:26:15] :     [Step 1/1] 16:26:05.213 [QUIET] [system.out] Step 2/33 : LABEL MAINTAINER 'dev@<placeholder>.com'
[16:26:15] :     [Step 1/1] 16:26:05.213 [QUIET] [system.out]  ---> Using cache
[16:26:15] :     [Step 1/1] 16:26:05.213 [QUIET] [system.out]  ---> 14bff4363c7f
... 

Then it continues to build normally with no errors!然后它继续正常构建,没有错误!

Here's the a failing build run on the exact same machine and exact same parameters这是在完全相同的机器和完全相同的参数上运行的失败构建

[15:53:03] :     [Step 1/1] 15:52:37.030 [QUIET] [system.out] Getting artifact
[15:53:03] :     [Step 1/1] 15:52:38.608 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Execute doFirst {} action for :clusterservice:createDocker'
[15:53:03] :     [Step 1/1] 15:52:38.609 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute doFirst {} action for :clusterservice:createDocker' completed
[15:53:03] :     [Step 1/1] 15:52:38.609 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute build for :clusterservice:createDocker' started
[15:53:03] :     [Step 1/1] 15:52:38.609 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Setting up staging directory.
[15:53:03] :     [Step 1/1] 15:52:38.612 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Creating Dockerfile from file /opt/teamcity/agent/work/7fe8da50bfc4c49f/clusterservice/build-gradle/docker/Dockerfile.
[15:53:03] :     [Step 1/1] 15:52:38.645 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Determining image tag: <placeholder>/<placeholder>-clusterservice:8.23.0-SNAPSHOT
[15:53:03] :     [Step 1/1] 15:52:38.645 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Using the native docker binary.
[15:53:03] :     [Step 1/1] 15:53:03.859 [LIFECYCLE] [org.gradle.process.internal.health.memory.MemoryManager] 
[15:53:03] :     [Step 1/1] 15:53:03.859 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 33737138176, Free: 26021330944}
[15:53:03] :     [Step 1/1] 15:53:03.859 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 33737138176, Free: 26021330944}
[15:53:03] :     [Step 1/1] 15:53:03.859 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 1908932608, Committed: 1186463744}
[15:53:08] :     [Step 1/1] 15:53:08.859 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 33737138176, Free: 26022682624}
[15:53:08] :     [Step 1/1] 15:53:08.859 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 33737138176, Free: 26022682624}
[15:53:08] :     [Step 1/1] 15:53:08.859 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 1908932608, Committed: 1186463744}
[15:53:11] :     [Step 1/1] 15:53:11.450 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
[15:53:11] :     [Step 1/1] 15:53:11.450 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
[15:53:11] :     [Step 1/1] 15:53:11.450 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
...

It doesn't error out, and the health check repeats and runs indefinitely (I let it run over 2 hours) and it just continues to hang without any errors.它不会出错,并且运行状况检查会重复并无限期地运行(我让它运行了 2 个小时以上),它只是继续挂起而没有任何错误。 I have no clue what's wrong with it, the build runs completely fine if I run the commands manually.我不知道它有什么问题,如果我手动运行命令,构建运行完全正常。 If it works the build takes around 7 minutes or so.如果它有效,构建大约需要 7 分钟左右。 Please help.请帮忙。

It appears that development on the project for this specific docker gradle plugin has been abandoned.似乎已放弃针对此特定 docker gradle 插件的项目开发。

If you check the issue on this github page here https://github.com/Transmode/gradle-docker/issues/119 and here https://github.com/Transmode/gradle-docker/issues/37 you will see that this issue was reported years ago but no fix has ever been merged in.如果您检查此 github 页面上的问题https://github.com/Transmode/gradle-docker/issues/119和此处Z5E056C500A1C4B6A7110B50D4B6A7110B50D807将看到docker thatTransmode/issues.com这个问题是几年前报告的,但从未合并过任何修复程序。

There are other gradle docker plugins that are available that are a bit more active in development which you could use.还有其他可用的 gradle docker 插件在开发中更加活跃,您可以使用它们。 This one https://github.com/bmuschko/gradle-docker-plugin comes to mind.想到这个https://github.com/bmuschko/gradle-docker-plugin

Personally in the end after getting incredibly fed up with all of this I just rewrote everything in a bash script and used gradle to call said script in order to do my necessary docker configuration.就个人而言,在厌倦了这一切之后,我只是在 bash 脚本中重写了所有内容,并使用 gradle 调用所述脚本以执行我必要的 Z05B6053C41A2130AFD6FC3B158BDA4E6 配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM