Interview Prep/Docker/Build Performance & CI

How do you build a small Java image?

BeginnerProductionBuild Performance & CI
Answer

Build the jar with Maven/Gradle in a JDK stage (cache ~/.m2 with a cache mount), then run on a JRE-only base such as eclipse-temurin:21-jre-alpine or distroless java21. Use Spring Boot layered jars (java -Djarmode=tools extract --layers) so dependency layers cache separately from app classes, and set -XX:MaxRAMPercentage=75.

All Docker questions Roadmap: Docker & containers

More on Build Performance & CI