Simple template for building a Spring Boot Demo application into a container image using the Jib maven plugin.
The Jib maven plugin can be used to create a container image:
-
The jib plugin can build a tar archive of the image using the
jib:buildTar
goal. This can be loaded into a minikube cluster withminikube image load <image.tar>
etc..The
jib:dockerBuild
goal can build the image directly to a docker daemon running running in a minikube cluster, if the required environment variables are set correctly. The output fromminikube docker-env
can be used to set the correct environment variables.(This should also work with either a local docker daemon, but I have not tested this.)
-
mvn clean compile jib:buildTar
, creates a tar archive that can be loaded to the internal minikube cluster repo with the command:minikube image load <image.tar>
) -
Use other mvn build profiles to build from a different image base or with different options (See 'pom.xml'):
mvn clean compile jib:buildTar -P distroless
defaultmvn clean compile jib:buildTar -P amazoncorretto
mvn clean compile jib:buildTar -P amazonlambda
-
Deploy image after build into docker (requires running local docker instance or other configuration.):
mvn clean compile jib:dockerBuild
See the reference documentation for more detailed information:
Basic demo Spring Boot Demo application generated by spring initializer at start.spring.io.