Add jib: Spring Boot 4.2.0 images with Jib 3.5.2 vs Buildpacks

Same app built both ways: layers, reproducible digest, extraDirectories, registry push
without a daemon, wrong-JRE and missing-compile failures, Buildpacks memory calculator at
512 MB. Captured output in jib/output, regenerated by jib/scripts/run-all.sh.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b6ZEVHGaYy15HAxRzy
This commit is contained in:
Ankur Mhatre
2026-12-01 08:32:09 +05:30
co-authored by Claude Sonnet 5.5
parent ddc3ec9d90
commit bb12eaca0a
30 changed files with 744 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
=== Toolchain ===
openjdk version "25.0.5.1" 2026-11-17 LTS
OpenJDK Runtime Environment Temurin-25.0.5.1+2 (build 25.0.5.1+2-LTS)
OpenJDK 64-Bit Server VM Temurin-25.0.5.1+2 (build 25.0.5.1+2-LTS, mixed mode, sharing)
Apache Maven 3.9.11 (3e54c93a704957b63ee3494413a2b544fd3d825b)
Java version: 25.0.5.1, vendor: Eclipse Adoptium, runtime: /tmp/tools/jdk-25.0.5.1+2
Docker engine 29.9.3
=== Versions pinned by the module ===
<version>4.2.0</version>
<java.version>25</java.version>
<jib.version>3.5.2</jib.version>
=== Base image used for Jib (digest of the local copy) ===
JIB_BASE=docker://eclipse-temurin:25-jre
id=sha256:4ed132f6832e9804b123e89a849a7b4502756ae64a4ee08ebab939d9d5d0a9fa
+56
View File
@@ -0,0 +1,56 @@
=== mvn jib:dockerBuild ===
$ mvn jib:dockerBuild -Djib.from.image=docker://eclipse-temurin:25-jre
[INFO] Containerizing application to Docker daemon as jib-demo, jib-demo:1.0.0...
[INFO] Building dependencies layer...
[INFO] Building resources layer...
[INFO] Building classes layer...
[INFO] Building extra files layer...
[INFO] Building jvm arg files layer...
[INFO] Container entrypoint set to [java, -XX:MaxRAMPercentage=75, -cp, @/app/jib-classpath-file, com.ankurm.jibdemo.JibDemoApplication]
[INFO] Built image to Docker daemon as jib-demo, jib-demo:1.0.0
[INFO] BUILD SUCCESS
[INFO] Total time: 6.894 s
=== Image config ===
tags=[jib-demo:1.0.0 jib-demo:latest localhost:5000/jib-demo:1.0.0]
user=1000
created=1970-01-01T00:00:00Z
exposed=map[8080/tcp:{}]
entrypoint=["java","-XX:MaxRAMPercentage=75","-cp","@/app/jib-classpath-file","com.ankurm.jibdemo.JibDemoApplication"]
layers=11
size=540348618 bytes
=== Layers Jib added on top of the base image ===
12.3kB jib-maven-plugin:3.5.2
16.4kB jib-maven-plugin:3.5.2
32.8kB jib-maven-plugin:3.5.2
28.7kB jib-maven-plugin:3.5.2
22.2MB jib-maven-plugin:3.5.2
=== What is inside /app (no fat jar) ===
classes
jib-classpath-file
jib-main-class-file
libs
resources
HdrHistogram-2.2.2.jar
commons-logging-1.4.0.jar
jackson-annotations-2.21.jar
jackson-core-3.1.8.jar
jackson-databind-3.1.8.jar
... 49 jars in /app/libs
/app/classes:
com
/app/resources:
application.properties
com
jib-demo image: this file came from src/main/jib/etc/motd.txt via extraDirectories
/app/resources
/app/classes
/app/libs/spring-boot-starter-webmvc-4.2.0.jar
+11
View File
@@ -0,0 +1,11 @@
=== docker run jib-demo:1.0.0 (memory limit 512m) ===
$ curl localhost:18080/hello
{"user":"ubuntu","maxHeapMb":371,"javaVersion":"25.0.5.1+2-LTS","greeting":"hello from a Jib image"}
$ curl localhost:18080/actuator/health
{"groups":["liveness","readiness"],"status":"UP"}
=== First lines of the container log ===
INFO 1 --- [jib-demo] [ main] com.ankurm.jibdemo.JibDemoApplication : Starting JibDemoApplication using Java 25.0.5.1 with PID 1 (/app/classes started by ubuntu in /)
INFO 1 --- [jib-demo] [ main] o.s.boot.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'
INFO 1 --- [jib-demo] [ main] com.ankurm.jibdemo.JibDemoApplication : Started JibDemoApplication in 2.919 seconds (process running for 3.306)
+22
View File
@@ -0,0 +1,22 @@
=== Build 1: unchanged source ===
a73f075296f4 19883908 bytes 49 files app/libs/HdrHistogram-2.2.2.jar
c40a9f3e76dd 466 bytes 1 files app/resources/application.properties
a44f4b821f44 1445 bytes 2 files app/classes/com/ankurm/jibdemo/HelloController.class
9a14dd547ae2 760 bytes 2 files app/jib-classpath-file
06bc0bf9c586 294 bytes 1 files etc/motd.txt
=== Edit one string in HelloController.java, then build 2 ===
a73f075296f4 19883908 bytes 49 files app/libs/HdrHistogram-2.2.2.jar
c40a9f3e76dd 466 bytes 1 files app/resources/application.properties
1059a437a912 1437 bytes 2 files app/classes/com/ankurm/jibdemo/HelloController.class
9a14dd547ae2 760 bytes 2 files app/jib-classpath-file
06bc0bf9c586 294 bytes 1 files etc/motd.txt
=== Layers whose digest changed (< build 1, > build 2) ===
< a44f4b821f44
> 1059a437a912
=== Files in the layer that changed ===
app/classes/com/ankurm/jibdemo/HelloController.class
app/classes/com/ankurm/jibdemo/JibDemoApplication.class
+10
View File
@@ -0,0 +1,10 @@
=== jib:buildTar twice, compare the image digest and id ===
build 1 digest=sha256:01832f5bfbd58a57428f3eeb51c374bcbd672413bdae004ca572497821897a10 id=sha256:35ae49d238eec2ce1035a26a4ac756a0b907e9078902ad28f2bda385ec9ca8d6
build 1 tar sha256 prefix=271ade52b5964451652d
build 2 digest=sha256:01832f5bfbd58a57428f3eeb51c374bcbd672413bdae004ca572497821897a10 id=sha256:35ae49d238eec2ce1035a26a4ac756a0b907e9078902ad28f2bda385ec9ca8d6
build 2 tar sha256 prefix=271ade52b5964451652d
=== Same build with creationTime=USE_CURRENT_TIMESTAMP ===
build 1 digest=sha256:4345a4fbc0cfb58ebf670afcddeedb2f7d3d3f513d9870e97ed1123390f58813
build 2 digest=sha256:093f5af3e98f69abc751cb7bd500da6fec95ac55f990e6b38766074ff904894d
+27
View File
@@ -0,0 +1,27 @@
=== mvn spring-boot:build-image (cold build: cleanCache=true; key lines of the build log) ===
[INFO] Building image 'docker.io/library/jib-demo:buildpacks'
===> BUILDING
Paketo Buildpack for CA Certificates 3.14.8
Paketo Buildpack for BellSoft Liberica 11.10.6
Using Java version 25 extracted from MANIFEST.MF
BellSoft Liberica JRE 25.0.5: Contributing to layer
Downloading from https://github.com/bell-sw/Liberica/releases/download/25.0.5.1+5/bellsoft-jre25.0.5.1+5-linux-amd64.tar.gz
Paketo Buildpack for Syft 2.44.2
Downloading from https://github.com/anchore/syft/releases/download/v1.57.1/syft_1.57.1_linux_amd64.tar.gz
Paketo Buildpack for Executable JAR 6.17.9
Paketo Buildpack for Spring Boot 5.41.1
[INFO] Successfully built image 'docker.io/library/jib-demo:buildpacks'
[INFO] BUILD SUCCESS
[INFO] Total time: 18.197 s
=== Image config ===
tags=[jib-demo:buildpacks]
user=1002:1001
created=1980-01-01T00:00:01Z
entrypoint=["/cnb/process/web"]
layers=18
size=658601199 bytes
=== Wall time of this build (seconds, indicative) ===
20
+36
View File
@@ -0,0 +1,36 @@
=== Cold builds (Jib: local Jib cache removed; Buildpacks: cleanCache=true), seconds ===
jib cold: 9
buildpacks cold: 19
=== Warm rebuilds after a one-line change, seconds ===
jib warm: 10
buildpacks warm: 13
=== Images (docker image inspect) ===
jib-demo:1.0.0 size=540348618 layers=11 created=1970-01-01T00:00:00Z user=1000
jib-demo:buildpacks size=658601199 layers=18 created=1980-01-01T00:00:01Z user=1002:1001
=== Is there a shell in the final image? (docker run --entrypoint sh ... -c 'echo yes') ===
jib-demo:1.0.0 yes
jib-demo:buildpacks docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: exec: "sh": executable file not found in $PATH
=== Run each image under a memory limit ===
--- jib-demo:1.0.0 memory=512m
{"maxHeapMb":371,"user":"ubuntu","greeting":"hello from a Jib image","javaVersion":"25.0.5.1+2-LTS"}
container memory in use: 141.6MiB / 512MiB
INFO 1 --- [jib-demo] [ main] com.ankurm.jibdemo.JibDemoApplication : Started JibDemoApplication in 2.558 seconds (process running for 2.85)
--- jib-demo:buildpacks memory=512m
container exited with code 82
unable to calculate memory configuration
fixed memory regions require 591743K which is greater than 512M available for allocation: -XX:MaxDirectMemorySize=10M, -XX:MaxMetaspaceSize=79743K, -XX:ReservedCodeCacheSize=240M, -Xss1M * 250 threads
--- jib-demo:buildpacks memory=512m -e BPL_JVM_THREAD_COUNT=50
{"greeting":"hello from a Jib image","user":"cnb","maxHeapMb":131,"javaVersion":"25.0.5.1+5-LTS"}
container memory in use: 136.9MiB / 512MiB
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx137344K -XX:MaxMetaspaceSize=79743K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 512M, Thread Count: 50, Loaded Class Count: 11665, Headroom: 0%)
INFO 1 --- [jib-demo] [ main] com.ankurm.jibdemo.JibDemoApplication : Started JibDemoApplication in 3.036 seconds (process running for 3.359)
--- jib-demo:buildpacks memory=1g
{"javaVersion":"25.0.5.1+5-LTS","maxHeapMb":433,"user":"cnb","greeting":"hello from a Jib image"}
container memory in use: 132.4MiB / 1GiB
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx456832K -XX:MaxMetaspaceSize=79743K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 1G, Thread Count: 250, Loaded Class Count: 11665, Headroom: 0%)
INFO 1 --- [jib-demo] [ main] com.ankurm.jibdemo.JibDemoApplication : Started JibDemoApplication in 2.895 seconds (process running for 3.259)
+22
View File
@@ -0,0 +1,22 @@
=== 1. jib:buildTar without compiling first (target/ was just cleaned) ===
$ mvn clean jib:buildTar
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.5.2:buildTar (default-cli) on project jib-demo: Obtaining project build output files failed; make sure you have compiled your project before trying to build the image. (Did you accidentally run "mvn clean jib:build" instead of "mvn clean compile jib:build"?): <module>/target/classes -> [Help 1]
=== 2. Base image older than the compiled bytecode (class files are Java 25, JRE is 21) ===
$ docker run jib-demo-wrongjre
Error: LinkageError occurred while loading main class com.ankurm.jibdemo.JibDemoApplication
java.lang.UnsupportedClassVersionError: com/ankurm/jibdemo/JibDemoApplication has been compiled by a more recent version of the Java Runtime (class file version 69.0), this version of the Java Runtime only recognizes class file versions up to 65.0
=== 3. Heap size at a 512 MB container limit: JVM default vs -XX:MaxRAMPercentage=75 ===
MaxRAMPercentage=25
size_t MaxHeapSize = 134217728 {product} {ergonomic}
MaxRAMPercentage=75
size_t MaxHeapSize = 402653184 {product} {ergonomic}
=== 4. containerizingMode=packaged after mvn package (Spring Boot repackaged the jar) ===
22327669 target/jib-demo-1.0.0.jar
4562 target/jib-demo-1.0.0.jar.original
$ docker run --rm --entrypoint ls -l /app/classpath
4562 jib-demo-1.0.0.original.jar
INFO 1 --- [jib-demo] [ main] com.ankurm.jibdemo.JibDemoApplication : Started JibDemoApplication in 2.697 seconds (process running for 3.013)
+26
View File
@@ -0,0 +1,26 @@
=== mvn jib:build to localhost:5000 (base image pulled from public.ecr.aws/docker/library/eclipse-temurin:25-jre) ===
$ mvn compile jib:build -Dimage.name=localhost:5000/jib-demo -Djib.allowInsecureRegistries=true
[INFO] Containerizing application to localhost:5000/jib-demo, localhost:5000/jib-demo:1.0.0...
[INFO] Getting manifest for base image public.ecr.aws/docker/library/eclipse-temurin:25-jre...
[INFO] Building dependencies layer...
[INFO] Building classes layer...
[INFO] Building extra files layer...
[INFO] Building jvm arg files layer...
[INFO] Building resources layer...
[INFO] Using base image with digest: sha256:4ed132f6832e...
[INFO] Built and pushed image as localhost:5000/jib-demo, localhost:5000/jib-demo:1.0.0
[INFO] BUILD SUCCESS
=== What the registry now holds ===
$ curl localhost:5000/v2/_catalog
{"repositories":["jib-demo"]}
$ curl localhost:5000/v2/jib-demo/tags/list
{"name":"jib-demo","tags":["latest","1.0.0"]}
$ manifest media type and layer count
application/vnd.docker.distribution.manifest.v2+json layers: 11
=== Pull and run what Jib pushed ===
jib-demo image: this file came from src/main/jib/etc/motd.txt via extraDirectories
+8
View File
@@ -0,0 +1,8 @@
=== mvn compile jib:buildTar with no base-image override (java.version=25 in the pom) ===
$ mvn compile jib:buildTar
[INFO] Getting manifest for base image eclipse-temurin:25-jre...
[INFO] BUILD FAILURE
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.5.2:buildTar (default-cli) on project jib-demo: 429 Too Many Requests
[ERROR] GET https://registry-1.docker.io/v2/library/eclipse-temurin/manifests/25-jre
[ERROR] {"errors":[{"code":"TOOMANYREQUESTS","message":"You have reached your unauthenticated pull rate limit. Sign in for a higher limit: https://www.docker.com/increase-rate-limit"}]}