Spring Boot 2.3 introduced support for building optimized Docker images using the Spring Boot maven/gradle plugin. The spring-boot:build-image
goal does a bunch of things:
- Create the layers index
- Invoke the Paketo buildpack
- Build the OCI image
- etc.
Is there a way to replicate these steps for modules using an older Spring Boot version? Even better, can these steps be integrated directly into a maven/gradle build?
As the layered jars feature (incl.
layers.idx
file generation and spring-boot-maven-plugin support for Cloud Native Buildpacks / Paketo.io) was introduced in Spring Boot 2.3 I would say that you can't really downgrade it with the standard tooling.BUT I guess you could try to generate the
layers.idx
file yourself - or even choose a default file, since the layout of your app may not change that much after all. A example would be (using noSNAPSHOT
depencencies):Having this file in place (means place it into your
target
folder (maybe you could automate that with a simple Maven plugin for example)), pack CLI should be able to pick it up. So install pack CLI and run a Paketo build without using thespring-boot-maven-plugin
yourself like this:I didn't really tried this approach myself - and maybe you run into problems, if the directory structure is much different in older Spring Boot versions. But I would appreciate to hear some feedback!