Having a Spring Boot app I tried to build it using the spring-boot-maven-plugin goal mvn spring-boot:build-image. But the build fails downloading the bellsoft-jre11.0.9.1+1-linux-amd64.tar.gz from github.com, since I don't have access to it from my build pipeline:
...
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
Is there a way I can download the bellsoft-jdk11.0.9.1+1-linux-amd64.tar.gz to a location accessible to my build pipeline and configure the bellsoft-liberica buildpack to use this instead?
According to the docs:
Configuring bindings using the spring-boot-maven-plugin (or the Gradle plugin) requires Spring Boot 2.5+. If you are on an older version, you need to upgrade or switch over to pack CLI.
=== Use pack CLI with bindings to configure a different JDK download uri ===
The pack docs tell us about the general layout of a binding directory (
/platform/bindingsis later created inside the pack build container):1. Create bindings directory
So let's try to create a fully running example! In order to hand over the binding configuration to
packCLI we need to create a directory first:2. Create file type, containing the binding key
Now we need to create a file called
typeinside this directory containing the binding key for the bellsoft-liberica binding typedependency-mapping:A new file
typeshould be present in the directory containing the stringdependency-mapping.3. Choose JDK version from buildpack.toml
As we want to change the bellsoft-liberica's download uri of the JDK, we need to decide which JDK version we exaclty want to use. The bellsoft-liberica buildpack's buildpack.toml gives an overview on which JRE/JDK versions are available inside the buildpack. For this example here I used the latest JDK version
11which is configured inside thebuildpack.tomllike this:4. Download JDK
Having decided on the version, we need to download the JDK from the location provided inside the
urifield to a location we have access to later inside our build environment (since we don't have access to github.com). Let's assume, we have the JDK downloaded and available athttp://your-accessible-uri-to/bellsoft-jdk11.0.9.1+1-linux-amd64.tar.gz.5. Create file named as the sha256, containing the JDK uri
Now we should create another file named exactly according to the
sha256digest value of the[[metadata.dependencies]]section of the JDK version we chose inside the buildpack.toml. This file must contain the uri of our downloaded JDK:In the end our directory
bellsoft-jdk-configshould comply to the pack CLI bindings directory docs and looks somehow like this:6. Execute pack CLI with --volume for binding & BP_JVM_VERSION
Finally we can issue our
packCLI command. Ensure that pack CLI is installed on your system. Be also sure to also provide the exact JDK version number using the--env BP_JVM_VERSION=exactJDKversionNumberHereenvironment variable configuration, which matches your downloaded JDK version and the section in the buildpack.toml:Now the bellsoft-liberica buildpack will download the JDK tar.gz from
http://your-accessible-uri-to/bellsoft-jdk11.0.9.1+1-linux-amd64.tar.gz: