Member-only story
Spring Boot 3.0 API deployment using Jenkins pipeline and Docker
In this story, we’ll explain step by step how to deploy a Spring boot application using Jenkins pipeline and Docker.
· Prerequisites
· Spring boot application setup
∘ Project Structure
∘ Containerize application
· Github
· Configure Jenkins
· Build Jenkins pipeline job
· Conclusion
· References
Prerequisites
This is the list of all the prerequisites for following this story:
- Spring Boot 3
- Maven 3.6.+
- Java 17
- A GitHub repository
- Git
- Jenkins instance installed
- Docker installed
- Docker compose installed
- PostgreSQL
- Postman / insomnia or any other API testing tool (optional)
Spring boot application setup
Suppose we already have a simple Spring Boot Rest API that exposes book endpoints. The application is connected to the PostgreSQL database.
Project Structure
Here is our project structure:
It works when trying to retrieve the list of books.
Containerize application
- Dockerfile
To build the container image with docker, we’ll need to use a file Dockerfile. A Dockerfile is simply a text-based file with no file extension that contains a script of instructions. Docker uses this script to build a container image. The file must be created at the root of the project.
# creates a layer from the openjdk:17-alpine…