Why this matters
- "Works on my machine" disappears when the same Docker image runs in dev, staging, and production — only environment variables change.
- Kubernetes rolling updates deploy new BookStore versions with zero downtime by gradually replacing pods while readiness probes gate traffic.
- Graceful shutdown ensures in-flight checkout requests complete before the pod terminates, preventing lost orders during deploys.
Container image
L1 · FresherPackage Boot JAR in a distroless or slim JRE image; run as non-root user.
Health probes
L2 · IntermediateWire liveness/readiness to actuator health groups that include database checks.
Resources limits
L3 · AdvancedSet CPU/memory requests and limits based on load tests — JVM needs headroom for GC.
12-factor config
L4 · ExpertInject config via env vars and secrets; never bake environment-specific URLs into images.
StreamHub production architecture (AWS)
Deployment essentials
- Multi-stage Dockerfile — build with Maven in one stage, run a slim JRE image in the final stage.
- Liveness probe — restarts the pod if the JVM is wedged; hits
/actuator/health/liveness. - Readiness probe — removes the pod from load balancing until it can serve traffic.
- Resource limits —
requestsandlimitsfor CPU and memory prevent one pod from starving the node. - Graceful shutdown —
server.shutdown: graceful+terminationGracePeriodSecondslet requests drain.
Production Dockerfile
# Build stage
FROM eclipse-temurin:21-jdk-alpine AS build
WORKDIR /app
COPY mvnw pom.xml ./
COPY .mvn .mvn
RUN ./mvnw dependency:go-offline -B
COPY src ./src
RUN ./mvnw package -DskipTests -B
# Runtime stage
FROM eclipse-temurin:21-jre-alpine
RUN addgroup -S bookstore && adduser -S bookstore -G bookstore
WORKDIR /app
COPY --from=build /app/target/bookstore-api-*.jar app.jar
USER bookstore
EXPOSE 8080
ENTRYPOINT ["java", \
"-XX:+UseContainerSupport", \
"-XX:MaxRAMPercentage=75.0", \
"-Djava.security.egd=file:/dev/./urandom", \
"-jar", "app.jar"]
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 3 sections
- Graceful shutdown configuration
- Kubernetes deployment manifest
- Build and deploy pipeline
Test yourself
Answer these before moving on — recall is what makes it stick.