Photo by Andrik Langfield / Unsplash

Sample App: Spring Boot Rest API Example With Dockerfile - Java

Jun 20, 2024

In the recent days I always wanted to have a Sample app or an example app which should expose Rest API and also it should be dockerised.

Eventhough there are many source codes available in github it hardly works as certain dependencies might have been outdated. Hence I found a recent code , forked and created my own dockerfile and tested with a docker compose.

So anyone can use this source code to test RestAPI , docker deployments for CICD, or practise for ECS and Kuberenetes deployments with any managed services like EKS, AKS, GKE

Repo Url: https://github.com/reyparthi/springboot_crud_postgres

From the Readme

Prerequisite

Docker Desktop

Test in Local

docker compose up -d

By using postman or curl you can verify the app,

GET: http://localhost:8080/api/v1/employees
POST: http://localhost:8080/api/v1/employees

{
    "firstName" : “Test”,
    "lastName" : “User”,
    "email" : “testemail@example.app"
}

If the Post creation works , then you can also verify the postgres db for entries in the employee table.

If you have any queries do post in the comment , I am happy to help.