使用Java/Spring引导的云本地BuildPack/Paketo:如何配置不同的JDK下载uri(例如,无法访问github.com)
有了Spring Boot应用程序,我尝试使用spring-boot-maven-plugin
目标mvn spring-boot:build-image
构建它。但是构建无法从github.com
下载bellsoft-jre11.0.9.1+1-linux-amd64.tar.gz
,因为我无法从构建管道访问它:
...
Paketo BellSoft Liberica Buildpack 5.2.1
https://github.com/paketo-buildpacks/bellsoft-liberica
Build Configuration:
$BP_JVM_VERSION 11.0.9 the Java version
Launch Configuration:
$BPL_JVM_HEAD_ROOM 0 the headroom in memory calculation
$BPL_JVM_LOADED_CLASS_COUNT 35% of classes the number of loaded classes in memory calculation
$BPL_JVM_THREAD_COUNT 250 the number of threads in memory calculation
$JAVA_TOOL_OPTIONS the JVM launch flags
BellSoft Liberica JDK 11.0.9: Contributing to layer
Downloading from https://github.com/bell-sw/Liberica/releases/download/11.0.9.1+1/bellsoft-jdk11.0.9.1+1-linux-amd64.tar.gz
unable to invoke layer creator
unable to get dependency jdk
unable to download https://github.com/bell-sw/Liberica/releases/download/11.0.9.1+1/bellsoft-jdk11.0.9.1+1-linux-amd64.tar.gz
unable to request https://github.com/bell-sw/Liberica/releases/download/11.0.9.1+1/bellsoft-jdk11.0.9.1+1-linux-amd64.tar.gz
ERROR: failed to build: exit status 1
有没有办法将bellsoft-jdk11.0.9.1+1-linux-amd64.tar.gz
下载到我的构建管道可以访问的位置,并配置bellsoft liberica buildpack来使用它
# 1 楼答案
@jonashackt我有一个解决这个问题的方法,它可以工作
我创建绑定
然后创建一个Dockerfile来复制这些绑定,并在前一个绑定的基础上构建一个新平台
然后我配置了spring插件来使用这个平台
此解决方法有效,但您必须使用正确的目录权限
你试过这样的解决办法吗
# 2 楼答案
@jonashackt:-我试着改变JRE。我想使用OpenJRE 15,因为我在默认版本中面临字体问题-https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk15u-2021-01-22-02-31/OpenJDK15U-jre_x64_linux_hotspot_2021-01-22-02-31.tar.gz
上述uri位于sha文件中
执行以下命令
c:\Mine>;包构建--清除缓存springbootapp映像--路径myspringboot应用--卷bellsoft jdk配置:/platform/bindings/bellsoft jdk配置--环境BP_JVM_VERSION=15--生成器PakeToBuildPack/builder:base
但它仍然下载BellSoft Liberica JRE 15.0.2
这是否意味着我无法覆盖以打开JRE?请分享你的想法
# 3 楼答案
According to the docs:
使用SpringBootMaven插件(或Gradle插件)配置绑定需要SpringBoot2.5+。如果您使用的是旧版本,则需要升级或切换到pack CLI
==使用带有绑定的pack CLI来配置不同的JDK下载uri==
The pack docs告诉我们绑定目录的总体布局(
/platform/bindings
稍后在包构建容器中创建):1。创建绑定目录
因此,让我们尝试创建一个完全运行的示例!为了将绑定配置移交给
pack
CLI,我们需要先创建一个目录:2。创建包含绑定密钥的文件类型
现在我们需要在这个目录中创建一个名为} 的绑定键:
type
的文件,其中包含the bellsoft-liberica binding type ^{包含字符串
dependency-mapping
的目录中应存在一个新文件type
3。从buildpack中选择JDK版本。汤姆
当我们想要更改bellsoft liberica的JDK下载uri时,我们需要决定我们确实想要使用哪个JDK版本bellsoft liberica构建包的buildpack.toml概述了构建包中提供的JRE/JDK版本。对于本例,我使用了最新的JDK版本
11
,该版本在buildpack.toml
内部配置如下:4。下载JDK
在决定了版本之后,我们需要将JDK从
uri
字段中提供的位置下载到构建环境中稍后可以访问的位置(因为我们没有访问github.com的权限)。让我们假设,我们已经下载了JDK,并且可以在http://your-accessible-uri-to/bellsoft-jdk11.0.9.1+1-linux-amd64.tar.gz
上找到它5。创建名为sha256的文件,其中包含JDK uri
现在,我们应该创建另一个文件,该文件的命名完全符合我们在buildpack.toml中选择的JDK版本的
[[metadata.dependencies]]
部分的sha256
摘要值。此文件必须包含我们下载的JDK的uri:最后,我们的目录
bellsoft-jdk-config
应该符合the pack CLI bindings directory docs的要求,并且看起来像这样:6。使用--volume for binding执行pack CLI&;BP_JVM_版本
最后,我们可以发出
pack
CLI命令。确保pack CLI is installed on your system。还要确保使用--env BP_JVM_VERSION=exactJDKversionNumberHere
{a9}提供确切的JDK版本号,它与下载的JDK版本和buildpack.toml中的部分相匹配:现在bellsoft liberica构建包将下载JDK tar。gz来自
http://your-accessible-uri-to/bellsoft-jdk11.0.9.1+1-linux-amd64.tar.gz
:# 4 楼答案
这对我有帮助。你可以试试看。 我在pom中更改了java版本。xml到17