Files
java-devops-demo/jib/scripts/09-registry-push.sh
T
Ankur MhatreandClaude Sonnet 5.5 bb12eaca0a 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
2026-12-01 08:32:09 +05:30

27 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# jib:build: build and push straight to a registry, with no Docker daemon involved in the build.
# The base image comes from a registry too (ECR Public mirror of Docker Official Images), so the
# whole pipeline is registry -> Jib -> registry.
source "$(dirname "$0")/lib.sh"
BASE_REG=public.ecr.aws/docker/library/eclipse-temurin:25-jre
docker rm -f local-registry >/dev/null 2>&1 || true
docker run -d --name local-registry -p 5000:5000 registry:2 >/dev/null
sleep 2
{
banner "mvn jib:build to localhost:5000 (base image pulled from $BASE_REG)"
echo '$ mvn compile jib:build -Dimage.name=localhost:5000/jib-demo -Djib.allowInsecureRegistries=true'
"${MVN[@]}" compile jib:build -Dimage.name=localhost:5000/jib-demo -Djib.allowInsecureRegistries=true -Djib.from.image=$BASE_REG 2>&1 \
| sed -n '/--- jib:/,$p' | grep -E 'Containerizing|Getting manifest|Building|Pushing|Using base|Built and pushed|BUILD' | sed -E 's/with digest: sha256:([0-9a-f]{12})[0-9a-f]+/with digest: sha256:\1.../'
banner "What the registry now holds"
echo '$ curl localhost:5000/v2/_catalog'; curl -s localhost:5000/v2/_catalog; echo
echo '$ curl localhost:5000/v2/jib-demo/tags/list'; curl -s localhost:5000/v2/jib-demo/tags/list; echo
echo '$ manifest media type and layer count'
curl -s -H 'Accept: application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json' localhost:5000/v2/jib-demo/manifests/1.0.0 \
| python3 -c 'import sys,json; m=json.load(sys.stdin); print(m["mediaType"], "layers:", len(m["layers"]))'
banner "Pull and run what Jib pushed"
docker rmi localhost:5000/jib-demo:1.0.0 >/dev/null 2>&1 || true
docker pull -q localhost:5000/jib-demo:1.0.0 >/dev/null
docker run --rm --entrypoint sh localhost:5000/jib-demo:1.0.0 -c 'cat /etc/motd.txt'
} 2>&1 | clean | tee "$OUT/09-registry-push.txt"
docker rm -f local-registry >/dev/null 2>&1 || true