How to build an OCI compliant docker image with Spring Boot 2.3.0
Installed on your machine:
- docker
- java 11
- clone this repository
- run
docker imagesand see the list of images you have locally - run
./gradlew bootBuildImagefrom this repo directory to generate an OCI image for this application - run
docker imagesand see the new images created - you should see also
spring-boot-build-docker-image-demoin the list now! - run it with
docker run spring-boot-build-docker-image-demo - you can see from the output that it's running with java 11
- uncomment the
bootBuildImagesection inbuild.gradle - run
./gradlew bootBuildImageagain to update the image - see how only the
jrelayer is updated - not even the app layer is updated (even though there's a change in
build.gradle!) - the app layer is not updated even if you add a new line anywhere on the source code!
- run your new image always with
docker run spring-boot-build-docker-image-demo - your app is now
- running with openjdk 14
- with just one line change on your gradle build file
- and only one layer (jdk) of the original image has been updated