Actually build-image use as default paketo-buildpacks/bellsoft-liberica:jre
but can be really cool thing adding possibility to chose witch jre buildpack to use (for example paketo-buildpacks/eclipse-openj9
)
Comment From: eddumelendez
@paulux84 spring-boot uses paketo buildpacks by default. In order to switch to eclipse-openj9
you can use the configuration below starting with 2.5
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>gcr.io/paketo-buildpacks/builder:base</builder>
<buildpacks>
<buildpack>gcr.io/paketo-buildpacks/eclipse-openj9:latest</buildpack>
<buildpack>gcr.io/paketo-buildpacks/executable-jar:latest</buildpack>
<buildpack>gcr.io/paketo-buildpacks/spring-boot:latest</buildpack>
</buildpacks>
<pullPolicy>IF_NOT_PRESENT</pullPolicy>
</image>
</configuration>
</plugin>
</plugins>
</build>
Comment From: scottfrederick
Closing as a duplicate of #21722.
Comment From: paulux84
hi @eddumelendez, thanks for the reply, but in this way i must specify all the buildpacks instead i suggest a way to selective substitute dafault buildpacks
Comment From: paulux84
@paulux84 spring-boot uses paketo buildpacks by default. In order to switch to
eclipse-openj9
you can use the configuration below starting with 2.5
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <image> <builder>gcr.io/paketo-buildpacks/builder:base</builder> <buildpacks> <buildpack>gcr.io/paketo-buildpacks/eclipse-openj9:latest</buildpack> <buildpack>gcr.io/paketo-buildpacks/executable-jar:latest</buildpack> <buildpack>gcr.io/paketo-buildpacks/spring-boot:latest</buildpack> </buildpacks> <pullPolicy>IF_NOT_PRESENT</pullPolicy> </image> </configuration> </plugin> </plugins> </build>
p.s. if i use this configuration (spring-boot-strarter-parent:2.5.0-M2) i get ERROR: No buildpack groups passed detection...while using manual pack command all detectors pass
Comment From: wilkinsona
That's been fixed in https://github.com/spring-projects/spring-boot/issues/25378. The change is available in 2.5.0-SNAPSHOT from https://repo.spring.io/snapshot and it'll be in next week's M3 release.
Comment From: scottfrederick
in this way i must specify all the buildpacks instead i suggest a way to selective substitute dafault buildpacks
This is consistent with the design of the pack
CLI. By design, platforms like the pack
CLI and the Spring Boot build plugins don't have deep knowledge of the builder that is being used, which buildpacks are included in the builder, or what role each buildpack plays in building an image. The Paketo builder is the default used by the Boot plugins, but any CNB-compatible builder can be used.
The minimal configuration to override the choice of JVM provider with the Paketo builder would be this:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<buildpacks>
<buildpack>gcr.io/paketo-buildpacks/eclipse-openj9:latest</buildpack>
<buildpack>paketo-buildpacks/java</buildpack>
</buildpacks>
</image>
</configuration>
</plugin>
</plugins>
</build>
This puts the eclipse-openj9
buildpack ahead of the bellsoft-liberica
buildpack that is included in paketo-buildpacks/java
, which results in bellsoft-liberica
backing off because a JVM is already provided. All other buildpacks included in paketo-buildpacks/java
that don't provide a JVM are still invoked as usual.
If you need more fine-grained control of the list of buildpacks that are involved and the order they are invoked without configuring it via the Spring Boot build plugin configuration, you should create a custom builder.
Comment From: paulux84
Really thanks for your explanation. Now is more clear for me how spring boot handle build-image...now i must wait the final release and other libs support (ex. spring cloud) Thanks again :) Have a nice day
Comment From: mancave
Can this feature also be implemented on the 2.4.x ?
Comment From: Been24
in this way i must specify all the buildpacks instead i suggest a way to selective substitute dafault buildpacks
This is consistent with the design of the
pack
CLI. By design, platforms like thepack
CLI and the Spring Boot build plugins don't have deep knowledge of the builder that is being used, which buildpacks are included in the builder, or what role each buildpack plays in building an image. The Paketo builder is the default used by the Boot plugins, but any CNB-compatible builder can be used.The minimal configuration to override the choice of JVM provider with the Paketo builder would be this:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <image> <buildpacks> <buildpack>gcr.io/paketo-buildpacks/eclipse-openj9:latest</buildpack> <buildpack>paketo-buildpacks/java</buildpack> </buildpacks> </image> </configuration> </plugin> </plugins> </build>
This puts the
eclipse-openj9
buildpack ahead of thebellsoft-liberica
buildpack that is included inpaketo-buildpacks/java
, which results inbellsoft-liberica
backing off because a JVM is already provided. All other buildpacks included inpaketo-buildpacks/java
that don't provide a JVM are still invoked as usual.If you need more fine-grained control of the list of buildpacks that are involved and the order they are invoked without configuring it via the Spring Boot build plugin configuration, you should create a custom builder.
The minimal configuration caused an Invalid buildpack reference 'gcr.io/paketo-buildpacks/eclipse-openj9:latest' error in springboot 2.5.4
Comment From: scottfrederick
The minimal configuration caused an Invalid buildpack reference 'gcr.io/paketo-buildpacks/eclipse-openj9:latest' error in springboot 2.5.4
@Been24 The configuration using gcr.io/paketo-buildpacks/eclipse-openj9:latest
still works for me. An "invalid buildpack reference" error could be caused by the Google Cloud Container Registry at gcr.io
not being available from your location. There's nothing Spring Boot can do about this, as GCR is where the Paketo project chooses to publish the buildpack images. You might be able to pull or build the required image and publish it to an alternate registry.