Companion code for "Dockerizing Spring Boot 4: Layered Jars, Buildpacks, Distroless and Image Size Benchmarks". Fat jar on JDK and JRE, layered jar on Debian, Alpine and distroless, jlink, the JDK 25 AOT cache, Paketo buildpacks and Jib, each measured for size on disk and pushed, rebuild delta, startup, user and shell. Also PID 1 and signal handling, the jdeps module gap, AOT cache mismatches and buildpacks memory calculation. Transcripts in docs/output/, regenerated by scripts/run-all.sh. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01C3TETMrqVUWeFkNtz3Jbo3
35 lines
1.9 KiB
Bash
35 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
# "A developer changed one line": bump BuildInfo.REVISION, rebuild every variant, and count the
|
|
# layers - and bytes - that differ from the previous build. That is what CI pushes and what every
|
|
# node pulls on the next rollout. -> docs/output/rebuild-delta.txt
|
|
# Run scripts/measure.sh first: it pushes the revision-1 images this compares against.
|
|
set -euo pipefail
|
|
source "$(dirname "$0")/env.sh"
|
|
cd "$MODULE_DIR"
|
|
FILE=src/main/java/com/ankurm/images/BuildInfo.java
|
|
trap 'sed -i "s/REVISION = \"2\"/REVISION = \"1\"/" "$FILE"; mvn -q -o -DskipTests package' EXIT
|
|
sed -i 's/REVISION = "1"/REVISION = "2"/' "$FILE"
|
|
mvn -q -o -DskipTests package
|
|
./scripts/build-images.sh -r2 > /dev/null
|
|
|
|
layers() { crane manifest "$1" | python3 -c 'import json,sys
|
|
for l in json.load(sys.stdin)["layers"]: print(l["digest"], l["size"])'; }
|
|
|
|
{
|
|
echo "# One-line code change (BuildInfo.REVISION 1 -> 2), every variant rebuilt."
|
|
echo "# 'new layers' = layer digests in revision 2 that revision 1 did not have: what a push uploads"
|
|
echo "# and what a node that already runs revision 1 downloads."
|
|
echo
|
|
printf '%-20s %12s %14s %14s %s\n' variant "new layers" "bytes to push" "image total" "share"
|
|
for v in "${VARIANTS[@]}"; do
|
|
docker tag "sbd/docker-images:$v-r2" "$REPO:$v-r2" && docker push -q "$REPO:$v-r2" > /dev/null
|
|
layers "$REPO:$v" | sort > /tmp/r1; layers "$REPO:$v-r2" | sort > /tmp/r2
|
|
new=$(comm -13 <(cut -d' ' -f1 /tmp/r1) <(cut -d' ' -f1 /tmp/r2))
|
|
count=$(echo "$new" | grep -c . || true)
|
|
bytes=0; for d in $new; do bytes=$(( bytes + $(grep "^$d " /tmp/r2 | cut -d' ' -f2) )); done
|
|
total=$(awk '{s+=$2} END {print s}' /tmp/r2)
|
|
printf '%-20s %6s of %-3s %13sK %13sM %5.1f%%\n' "$v" "$count" "$(wc -l < /tmp/r2)" "$(( bytes / 1000 ))" "$(( total / 1000000 ))" \
|
|
"$(python3 -c "print(100*$bytes/$total)")"
|
|
done
|
|
} | tee "$OUT/rebuild-delta.txt"
|