Spring Boot · Lesson 15 of 15
Docker, Profiles and Release
Layered jars, 12-factor config, graceful shutdown and health for orchestrators.
- Advanced
- 16 min read
- 3 objectives
Before this lessonLesson 14: Tests with Testcontainers
What you will learn
- Build an image
- Use profiles
- Shut down cleanly
Your Progress
0 of 15 lessons 0%
- Lessons0 / 15
- Completed0
- Est. time left~ 4 hours
Create a free account to keep your progress on every device.
Spring Boot 3 builds a layered jar that Docker can cache. Config stays in the environment; the process shuts down on SIGTERM.
Image
FROM eclipse-temurin:21-jre
WORKDIR /app
COPY build/libs/app.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-XX:MaxRAMPercentage=75","-jar","app.jar"]Profiles and shutdown
spring:
profiles:
active: ${APP_ENV:prod}
lifecycle:
timeout-per-shutdown-phase: 20s
server:
shutdown: gracefulThe load balancer should call /actuator/health/readiness. On SIGTERM, Boot stops taking new work, waits in-flight requests, then exits.
- Secrets and URLs from env, not
application.ymlcommitted to git. - Flyway/Liquibase migrate on startup or as a release job.
- Pin the Java and base image versions.
