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
3.5 KiB
3.5 KiB
jib: container images for Spring Boot without a Dockerfile
Companion module for the ankurm.com post Jib for Spring Boot: Container Images Without a Dockerfile (vs Buildpacks).
Everything in the post, including every transcript, comes from a file in this module. There is no docs/ folder on purpose:
the explanation lives in the post.
| Component | Version |
|---|---|
| Spring Boot | 4.2.0 (GA 2026-11-19) |
| jib-maven-plugin | 3.5.2 (Maven Central 2026-07-14) |
| JDK | Temurin 25.0.5.1+2 (LTS) |
| Buildpacks builder | paketobuildpacks/ubuntu-resolute-builder (Spring Boot 4.2 default), Liberica JRE 25.0.5 |
| Docker Engine | 29.9.3 |
Quickstart
export JAVA_HOME=/path/to/jdk-25
mvn compile jib:dockerBuild # image jib-demo:1.0.0 in the local Docker daemon
docker run -p 8080:8080 jib-demo:1.0.0
curl localhost:8080/hello
mvn spring-boot:build-image # the Buildpacks version of the same app: jib-demo:buildpacks
mvn jib:build (no compile) fails by design: Jib reads target/classes and does not compile for you
(scripts/08-failures.sh, scenario 1).
Files
| Path | What it is |
|---|---|
pom.xml |
Boot 4.2.0 parent, Jib plugin configuration, Buildpacks configuration, corp-proxy profile |
src/main/java/.../HelloController.java |
One endpoint that reports the JVM it runs on and its heap |
src/main/jib/etc/motd.txt |
Copied to /etc/motd.txt in the image by Jib's extraDirectories |
scripts/lib.sh |
Shared setup. JIB_BASE selects the base image source (see the comment inside) |
scripts/01..10-*.sh |
One script per scenario; each writes output/NN-*.txt |
scripts/run-all.sh |
Regenerates all of output/ (about four minutes) |
output/*.txt |
Captured real output, the evidence the post quotes |
Output index
| File | Shows |
|---|---|
01-versions.txt |
Toolchain and pinned versions |
02-jib-build.txt |
jib:dockerBuild, image config, the five layers Jib adds, contents of /app |
03-run.txt |
The Jib image running and answering |
04-layer-cache.txt |
One-line code change: which layer digests change |
05-reproducible.txt |
Two builds, identical digest; with USE_CURRENT_TIMESTAMP, different digests |
06-buildpacks.txt |
spring-boot:build-image cold build |
07-compare.txt |
Size, layers, build time, shell, memory behaviour at 512 MB and 1 GB |
08-failures.txt |
Missing compile, JRE older than bytecode, heap defaults, packaged mode |
09-registry-push.txt |
jib:build to a local registry, base image from a registry |
10-default-base.txt |
Which base image Jib picks when you do not say |
Reproducing in a restricted network
Two things in the capture environment differ from a normal laptop, and the scripts accommodate both:
- Docker Hub answered
429 Too Many Requestsfor anonymous pulls, soscripts/lib.shdefaults the Jib base todocker://eclipse-temurin:25-jre(the copy in the local daemon).JIB_BASE="" ./scripts/run-all.shlets Jib pull from the registry.09-registry-push.shusespublic.ecr.aws/docker/library/eclipse-temurin:25-jre, so it is daemon-free on both ends. - Buildpacks download the JRE from github.com inside the builder container, behind a TLS-intercepting proxy. The
corp-proxyprofile passes the proxy address and CA certificate to the builder (PROXY_URL,CA_DIR).
Timings in 07-compare.txt come from a two-core shared sandbox; they vary by 2x between runs and are only indicative.
MIT licensed (see the repository root).