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
16 lines
806 B
Docker
16 lines
806 B
Docker
# 5. Layered, on distroless: no shell, no package manager, runs as uid 65532 (the :nonroot tag).
|
|
# The extraction has to happen in a stage that HAS a shell - distroless cannot RUN anything.
|
|
FROM eclipse-temurin:25-jre AS builder
|
|
WORKDIR /builder
|
|
COPY target/app.jar application.jar
|
|
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted
|
|
|
|
FROM gcr.io/distroless/java25-debian13:nonroot
|
|
WORKDIR /application
|
|
COPY --from=builder /builder/extracted/dependencies/ ./
|
|
COPY --from=builder /builder/extracted/spring-boot-loader/ ./
|
|
COPY --from=builder /builder/extracted/snapshot-dependencies/ ./
|
|
COPY --from=builder /builder/extracted/application/ ./
|
|
# Exec form is mandatory here: there is no /bin/sh to run a shell-form command.
|
|
ENTRYPOINT ["java", "-jar", "application.jar"]
|