离线环境下无法使用 gradle bootBuildImage 构建镜像
Posted
技术标签:
【中文标题】离线环境下无法使用 gradle bootBuildImage 构建镜像【英文标题】:Unable to build image using gradle bootBuildImage in offline environment 【发布时间】:2021-03-28 09:22:06 【问题描述】:我正在尝试使用paketobuildpacks/builder:base
和paketobuildpacks/run:base-cnb
图像在离线环境中构建图像。我正在运行我通过http://start.spring.io/ 创建的demo spring-boot project
所以这是我用来构建图像的命令
gradle clean build bootBuildImage
在我的有互联网连接的机器上,一切正常,并且我能够成功构建映像。但是,当我将同一个项目带到我的离线环境并尝试做同样的事情时,它会引发一些错误。
唯一的区别是我需要在我的离线环境(build.gradle)中配置这个
bootBuildImage
builder = "myprivateartifactory/paketobuildpacks/builder:base",
runImage = "myprivateartifactory/paketobuildpacks/run:base-cnb"
以下是在启用 --debug
的情况下运行的 - gradle clean build bootBuildImage --debug
Gradle Test Executor 6 finished executing tests.
> Task :test
Finished generating test XML results (0.008 secs) into: C:\Users\joseph\Desktop\demo (9)\demo\build\test-results\test
Generating html test report...
Finished generating test html results (0.004 secs) into: C:\Users\joseph\Desktop\demo (9)\demo\build\reports\tests\test
:test (Thread[Execution worker for ':' Thread 7,5,main]) completed. Took 2.708 secs.
:check (Thread[Execution worker for ':' Thread 7,5,main]) started.
> Task :check
Skipping task ':check' as it has no actions.
:check (Thread[Execution worker for ':' Thread 7,5,main]) completed. Took 0.0 secs.
:build (Thread[Execution worker for ':' Thread 7,5,main]) started.
> Task :build
Skipping task ':build' as it has no actions.
:build (Thread[Execution worker for ':' Thread 7,5,main]) completed. Took 0.0 secs.
:bootBuildImage (Thread[Execution worker for ':' Thread 7,5,main]) started.
> Task :bootBuildImage
Caching disabled for task ':bootBuildImage' because:
Build cache is disabled
Task ':bootBuildImage' is not up-to-date because:
Task has not declared any outputs despite executing actions.
Building image 'docker.io/library/demo:0.0.1-SNAPSHOT'
> Pulling builder image 'cr.io/paketobuildpacks/builder:base' ..................................................
> Pulled builder image 'cr.io/paketobuildpacks/builder@sha256:dfbd2831033f37161f5027dfa46d5a658b29a3302c33aaf0219160a05fe5c12e'
> Task :bootBuildImage FAILED
:bootBuildImage (Thread[Execution worker for ':' Thread 7,5,main]) completed. Took 2.298 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootBuildImage'.
> No 'io.buildpacks.builder.metadata' label found in image config labels 'io.buildpacks.stack.description,io.buildpacks.stack.distro.name,io.buildpacks.stack.distro.version,io.buildpacks.stack.homepage,io.buildpacks.stack.id,io.buildpacks.stack.maintainer,io.buildpacks.stack.metadata,io.buildpacks.stack.mixins,io.buildpacks.stack.released'
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 7s
8 actionable tasks: 8 executed
设置:
spring-boot 2.4.1 / gradle 6.7.1
我做错了什么?如果需要更多信息,请告诉我
谢谢!
【问题讨论】:
***.com/questions/65336624/… 可能是相关的。 你可能是对的.. 似乎相关 我是添加我链接到的问题的人。我赞成您的问题以吸引更多关注。随意对***.com/questions/65336624/… 做同样的事情:) 谢谢! 为了避免重复支持,Spring Boot 问题跟踪器中也存在一个问题:github.com/spring-projects/spring-boot/issues/24641 您的私有 Artifactory 中 builder 镜像上的标签不正确。具体来说,缺少io.buildpacks.builder.metadata
标签。
【参考方案1】:
更多讨论请见spring-boot#24641。总之,上面提到的错误原因是使用了错误的图像。
【讨论】:
以上是关于离线环境下无法使用 gradle bootBuildImage 构建镜像的主要内容,如果未能解决你的问题,请参考以下文章
游戏开发进阶教你自制离线Maven仓库,实现Unity离线环境使用Gradle打包(Unity | Android | 谷歌 | Gradle)
游戏开发进阶教你自制离线Maven仓库,实现Unity离线环境使用Gradle打包(Unity | Android | 谷歌 | Gradle)