/spring-boot-jib-hello

Spring boot app configured to create container image with Jib

Primary LanguageJavaMIT LicenseMIT

Spring Boot Jib Hello web app

How this app was created

  1. This app is generated with Spring Initialzr with the added dependency Spring Reactive Web.

  2. Configure jar-maven-plugin to set Build date and Implementation version

  3. Add /sayhello service that greets you with the version and build time taken from MANIFEST.MF . This class iterates through available MANIFEST.MF files as suggested in this stackoverflow post and uses the title to find the correct file.

The implementation is tested manually by packaging the app:

mvn clean package -Dbuild.version=1.2.3

... running it with

java -jar target/spring-boot-jib-hello-0.0.1-SNAPSHOT.jar

... and finally accessing it with http://localhost:8080/sayhello . It shows something like Hello from 1.2.3 2020-06-03T09:25:58Z

  1. Add Jib configuration for creating an image that runs the packaged JAR Creating an image is done for instance with:
mvn clean package jib:dockerBuild -Dbuild.version=1.2.3

Running the created image with

docker run -d -p 8080:8080 spring-boot-jib-hello:1.2.3

... should bring the text Hello from 1.2.3 2020-06-03T12:22:44Z when accessing http://localhost:8080/sayhello.

Reference Documentation

For further reference, please consider the following sections: