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
23 lines
990 B
Bash
23 lines
990 B
Bash
#!/usr/bin/env bash
|
|
# Build every image variant from target/app.jar. Tag suffix is $1 (default: none).
|
|
# ./scripts/build-images.sh -> sbd/docker-images:<variant>
|
|
# ./scripts/build-images.sh -r2 -> sbd/docker-images:<variant>-r2
|
|
# Buildpacks and Jib need extra flags in a network-restricted environment; set
|
|
# BUILDPACKS_ARGS / JIB_ARGS (scripts/run-all.sh shows the sandbox values).
|
|
set -euo pipefail
|
|
source "$(dirname "$0")/env.sh"
|
|
SUFFIX="${1:-}"
|
|
cd "$MODULE_DIR"
|
|
for v in "${VARIANTS[@]}"; do
|
|
case "$v" in
|
|
buildpacks)
|
|
mvn -q -o -DskipTests ${BUILDPACKS_ARGS:-} -Dbuildpacks.image="sbd/docker-images:buildpacks$SUFFIX" \
|
|
spring-boot:build-image > /dev/null ;;
|
|
jib)
|
|
mvn -q -o -DskipTests ${JIB_ARGS:-} -Djib.to.image="sbd/docker-images:jib$SUFFIX" jib:dockerBuild > /dev/null ;;
|
|
*)
|
|
docker build -q -f "docker/Dockerfile.$v" -t "sbd/docker-images:$v$SUFFIX" . > /dev/null ;;
|
|
esac
|
|
echo "built sbd/docker-images:$v$SUFFIX"
|
|
done
|