1

I am using the spring-boot-maven-plugin in the latest version 2.4.0 to build images. https://docs.spring.io/spring-boot/docs/2.4.0/maven-plugin/reference/htmlsingle/#build-image

The documentation describes how the environment variables of the used buildbacks are set. https://docs.spring.io/spring-boot/docs/2.4.0/maven-plugin/reference/htmlsingle/#build-image-example-builder-configuration

But some of the configurations of the buildpacks are made with bindings. E.g. the dependency-mapping. https://github.com/paketo-buildpacks/bellsoft-liberica

How can one use these bindings with the spring-boot-maven-plugin?

SebastianP
  • 51
  • 1
  • 4
  • Hey [SebastianP](https://stackoverflow.com/users/14736809/sebastianp), [as the paketo docs state](https://paketo.io/docs/buildpacks/configuration/#bindings) bindings are commonly used to provide credentials, secrets etc. in a form, that the build image has access to it. Therefore normally [bindings are provided in form of Docker volume mounts or Kubernetes secrets](https://paketo.io/docs/buildpacks/configuration/#how-to-use-bindings). I guess providing a configuration abstraction for that wasn't the goal of the spring-boot-maven-plugin's buildpack/Paketo integration... – jonashackt Dec 04 '20 at 10:16
  • But maybe we're able to find a better answer to your question, if you ask yourself what your goal really is. Therefore let's elaborate on your phrase: "E.g. the dependency-mapping"? What do you exaclty mean with that? What do you want to achieve? Do you have an example GitHub project maybe to better show your use case? Maybe we can refactor your question a bit to find a suitable answer... – jonashackt Dec 04 '20 at 10:18
  • Hi @jonashackt ! Thank you for your response. Let me try to clarify my goal: The BellSoft Liberica Buildpack downloads JREs or JDKs from github.com. Gitlab.com is inaccessible from my build pipeline. The BellSoft Liberica Buildpack provides a [binding with type "dependency-mapping"](https://github.com/paketo-buildpacks/bellsoft-liberica#type-dependency-mapping) that can be used to map a new URI to a given dependency. – SebastianP Dec 07 '20 at 10:09
  • I want to use this binding to downlad a copy of the required JREs or JDKs from an accessible location as described [here](https://paketo.io/docs/buildpacks/configuration/#dependency-mappings) using the spring-boot-maven-plugin. Is there a way to do so? – SebastianP Dec 07 '20 at 10:09

1 Answers1

0

According to the docs:

Paketo Buildpacks may download dependencies from the internet. For example, the Java Buildpack will download the BellSoft Liberica JRE from the Liberica github releases by default. If a dependency URI is inaccessible from the build environment, a binding can be used to map a new URI to a given dependency.

AFAIK currently it isn't possible to define bindings through the spring-boot-maven-plugin. I also scanned some code of github.com/paketo-buildpacks/bellsoft-liberica but I didn't catch other/undocumented environment variables for that we could have used as a work-around. For now you need to stick with pack CLI and define a binding and substitute the mvn spring-boot:build-image command with this.

I can recommend this stackoverflow Q&A with the answer on how to use pack CLI with bindings to configure a different JDK download uri to solve your problem.

jonashackt
  • 12,022
  • 5
  • 67
  • 124
  • 1
    Thank you for the [detailed answer](https://stackoverflow.com/questions/65212231/cloud-native-buildpacks-paketo-with-java-spring-boot-how-to-configure-different) There is also an issue covering ths topic on github: https://github.com/spring-projects/spring-boot/issues/23518 – SebastianP Dec 14 '20 at 16:31
  • Ah good to see - but as I expected, the Spring dev team is also sceptical about implementing this feature in the `spring-boot-maven-plugin`. Maybe there comes a solution using a configuration file as [Stéphane Nicoll outlined](https://github.com/spring-projects/spring-boot/issues/23518#issuecomment-700497880)... But for now, you can use the bindings directly using pack CLI. – jonashackt Dec 15 '20 at 08:08
  • 2
    The Spring Boot dev team is not skeptical about implementing the bindings feature in the plugin. It's currently planned for a 2.5.0 release. The discussion in the issue is about whether the image configuration elements (including existing config and a new `` element ) should be in pom.xml directly or extracted to a separate XML file as was done with custom layers configuration (https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/#repackage-layers-configuration). – Scott Frederick Jan 27 '21 at 15:46
  • Good to know, that 2.5.x will come with support for bindings! – jonashackt Jan 27 '21 at 17:43