binding-tool icon indicating copy to clipboard operation
binding-tool copied to clipboard

Expand binding-tool to generate Spring Boot Maven & Gradle config snippets

Open dmikusa opened this issue 3 years ago • 7 comments

The binding-tool has helpers to make integrating with pack build easier, it should have commands to print out snippets of Maven or Gradle config to add for using it.

See SO

dmikusa avatar Nov 11 '22 18:11 dmikusa

Hi. @dmikusa

My server administrator does not allow me to install binding-tool on the server (as it has not been reviewed). How should I configure it in Spring boot Maven Plugin.

Can you make changes to the creator to make it compatible with configurations like this, making it easier to use local JRE

<binding>/path/to/local/jre/:/layers/paketo-buildpacks_bellsoft-liberica/jre:rw</binding>

devcxl avatar May 15 '23 12:05 devcxl

You don't need to install bt on any servers. It's really meant to be run on your local dev machine. If you want to use it in a production setting, I'd recommend having someone run it and then transfer the binaries to a place where they can easily be shared, like an HTTPS server.

When bt generates all of the binding files, it will assume that you're running locally and generate file:// links but if you just change those to https:// and point them to the HTTPS server where you're hosting the files then you can have them downloaded from your HTTPS server, likely on your LAN. Then just include your modified bindings with your project & when you run through CI or wherever you're building, you can tell it to use those bindings (see the SO post I linked above).

I have an open issue to allow bt to generate the binding files pointing to a remote server, but I'm not exactly sure how that feature should work. If you do go this route, feel free to drop in some comments about your use case/experience getting this to work. https://github.com/dmikusa/binding-tool/issues/4

dmikusa avatar May 15 '23 12:05 dmikusa

This method is too cumbersome. If the /tmp/{sha256sum} directory exists with an externally mounted JRE, could we add a condition when downloading the BellSoft Liberica JRE: if the JRE file exists in /tmp/{sha256sum}, use the mounted JRE; otherwise, download the JRE from GitHub.

[INFO]     [creator]       BellSoft Liberica JRE 8.0.312: Contributing to layer
[INFO]     [creator]       Check  /tmp/{sha256sum}/bellsoft-jre8u312+7-linux-amd64.tar.gz exists (like this)
[INFO]     [creator]         Downloading from https://github.com/bell-sw/Liberica/releases/download/8u312+7/bellsoft-jre8u312+7-linux-amd64.tar.gz

Simple, straightforward, yet effective, isn't it?

devcxl avatar May 15 '23 13:05 devcxl

The binding tool does nothing beyond creating the binding files. How those are used is defined by Paketo buildpacks. In short, binding tool cannot change how the buildpacks behave.

That said, if you don't have a binding present the buildpack will download from Github. If you do have a binding present, it will download from wherever the binding tells it to, a file:// URL or an https:// URL. So it kind of already does what you're proposing.

dmikusa avatar May 15 '23 13:05 dmikusa

First of all, I would like to express my gratitude for your thorough explanation. As English is not my native language, I may have misunderstood certain aspects of this project. However, after carefully reading through your response, I have gained a general understanding of the configuration process. I will give it a try shortly and provide you with feedback later. Thank you very much for your assistance.

devcxl avatar May 15 '23 14:05 devcxl

No worries & happy to help. There is also more context on bindings here -> https://paketo.io/docs/howto/configuration/#dependency-mappings

dmikusa avatar May 15 '23 14:05 dmikusa

This is an example of my successful configuration.

configuration

$ sha256sum /tmp/jre/bellsoft-jre8u312+7-linux-amd64.tar.gz
$ 9850e06b83c891bd96b1b3757e1d04a287800cb4c1e7dc5e3044e1967ce64ef6

/path/to/you/config/9850e06b83c891bd96b1b3757e1d04a287800cb4c1e7dc5e3044e1967ce64ef6

file:///tmp/jre/bellsoft-jre8u312+7-linux-amd64.tar.gz

/path/to/you/config/type

dependency-mapping

pom.xml

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>${spring-boot.version}</version>
    <configuration>
        <excludes>
            <exclude>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
            </exclude>
        </excludes>
        <image>
            ...
            <bindings>
                <binding>/path/to/you/config/:/platform/bindings/dependency-mapping/</binding>
                <binding>/path/to/jre/:/tmp/jre/</binding>
            </bindings>
        </image>
    </configuration>
</plugin>

reference

Additionally, how should Paketo Syft be configured. I haven't found any documentation about it, is it like bellsoft-jre configuration?

devcxl avatar May 15 '23 15:05 devcxl