This content originally appeared on DEV Community and was authored by DevCorner2
Containerizing applications is often seen as a Docker-first activity β you write a Dockerfile
, build an image, and push it to a registry. But modern platforms like Cloud Native Buildpacks (CNB) provide a more streamlined alternative.
With Spring Boot Buildpacks (Paketo), you can create production-ready container images without a Dockerfile, without Jib, and without deep Docker knowledge.
Why Buildpacks?
- No Dockerfile needed β everything is auto-generated.
- Best practices baked in (optimized base images, JVM tuning, layering).
- Works with any registry β Docker Hub, Harbor, ECR, GCR, ACR, etc.
- Direct Spring Boot support β works out-of-the-box with Maven and Gradle.
Step 1: Prerequisites
- Spring Boot 2.3+ (supports
build-image
). - Docker installed locally (for creating the image).
Step 2: Build an Image with Maven
Inside your Spring Boot project, simply run:
mvn spring-boot:build-image -Dspring-boot.build-image.imageName=myregistry.example.com:5000/myteam/myapp:1.0
What happens here:
- Spring Boot invokes Paketo Buildpacks.
- A JVM-optimized image is built.
- The image is tagged and ready.
Step 3: Build an Image with Gradle
If you use Gradle:
./gradlew bootBuildImage --imageName=myregistry.example.com:5000/myteam/myapp:1.0
Step 4: Push to Private Registry
After the image is built, tag and push it (if not already tagged):
docker push myregistry.example.com:5000/myteam/myapp:1.0
Step 5: Run the Image
Verify everything works:
docker run -p 8080:8080 myregistry.example.com:5000/myteam/myapp:1.0
Pro Tips
- Custom JDK version: Paketo auto-detects your projectβs JDK requirements.
- Layer caching: Faster rebuilds by reusing cached layers.
-
Zero-config builds: CI/CD-friendly β just run
mvn spring-boot:build-image
in pipelines. - Security updates: Base images are maintained and patched automatically.
Conclusion
With Spring Boot Buildpacks (Paketo) you get a zero-Dockerfile, zero-Jib alternative for building production-ready images.
Itβs ideal if:
- You want one command builds.
- Your organization mandates best-practice base images.
- Youβre deploying Spring Boot apps at scale on Kubernetes, Cloud Foundry, or Tanzu.
So now we have three structured approaches to containerize Java apps:
- Dockerfile β total control.
- Google Jib β no Docker, Maven/Gradle integrated.
- Spring Boot Buildpacks β zero config, production-ready defaults.
This content originally appeared on DEV Community and was authored by DevCorner2