Project 1: Spring Boot Banking App
Spring boot:
Spring Boot is used for building Java-based web applications quickly and easily, by providing pre-configured templates, tools, and libraries to set up, develop, and deploy production-ready applications with minimal effort. It simplifies the process of creating stand-alone, production-grade Spring-based applications.
Reference for code : (158) Code With GoldenCat - YouTube
PRE-REQUISITES FOR THIS PROJECT:
AWS Account
AWS Ubuntu EC2 instance (t2.medium)
Install Docker
Install docker compose
To clone the code from Git, you just need to copy a full version of a project from an online repository to your local machine. Here's how to do it in simple steps:
Copy the repository link: Go to the GitHub (or other Git service) page of the project and copy the link for cloning (usually found under a "Code" button).
Open your terminal: On your computer, open a terminal or command prompt.
Run the git clone command: Type
git clone
, paste the copied link, and press Enter. For example:ls : This will display all the files and directories in the current location.
- git clone to clone the code:
Pom.xml is similar to requirement.txt in python (pip install requirement.txt)
In Docker, both ENTRYPOINT
and CMD
are instructions used in a Dockerfile to define what command should run in a container. Although they are similar, they serve slightly different purposes.
Key Differences
ENTRYPOINT defines the main command that will always run, while CMD provides defaults that can be overridden.
If both
ENTRYPOINT
andCMD
are defined, CMD will provide arguments to theENTRYPOINT
.
Example Combining ENTRYPOINT and CMD
DockerfileCopy codeENTRYPOINT ["python"]
CMD ["app.py"]
In Docker, you can add a user to a new group within a Docker container by using the usermod
command in the Dockerfile or by specifying the group in the USER
instruction. Here’s how you can do it:
The docker build
command is used to create a Docker image from a Dockerfile and a context (a set of files at a specified location). Here’s a step-by-step guide on how it works and how to use it:
When you create a Spring Boot application and run it successfully, you will see a series of outputs in the console/logs indicating the progress and status of the application. Here’s what you can typically expect to see:
Next ,check the docker images via command docker images:
A Dockerfile is a text file containing instructions to build a Docker image. It defines the environment, dependencies, and commands needed to create a container that can run your application.
The docker run
command is used to create and start a container from a Docker image. This is one of the main commands in Docker, as it allows you to take a pre-built image and run it as an isolated environment on your system. Here’s what it does and how to use it.
What docker run
Does
Creates a Container:
docker run
takes an image and creates a new container from it.Starts the Container: Once the container is created,
docker run
starts it, executing any commands defined in the image (like theCMD
orENTRYPOINT
instructions in the Dockerfile).Allocates Resources: Docker allocates CPU, memory, network, and storage resources to the container.
Isolates Environment: Each container runs independently, isolated from other containers and the host machine.
-
We need to take username as mentioned below:
-
Creating bridge network one :
Docker logs :
Final output. bank app is ready:
Spring Boot facilitates the quick development of Java web applications by providing pre-configured templates and tools. This guide outlines the prerequisites for a Spring Boot project, including setting up an AWS EC2 instance and installing Docker. It explains how to clone code from a Git repository and offers an overview of Dockerfile instructions like ENTRYPOINT and CMD. The guide also covers Docker commands such as `docker build` and `docker run`, which are essential for creating and running containers, and highlights the process of viewing Docker images and logs during application deployment.
Happy learning!
Subscribe to my newsletter
Read articles from Shivani Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Shivani Singh
Shivani Singh
"Passionate about simplifying the complexities of DevOps, I bring 5 years of hands-on experience in supporting development and operations teams to achieve faster, more reliable software delivery. I thrive on optimizing CI/CD pipelines, automating workflows, and troubleshooting challenges across diverse cloud environments. My expertise spans across infrastructure management, continuous integration, and performance monitoring—ensuring stability and efficiency at every stage of the software lifecycle. Always eager to learn, collaborate, and innovate, I’m committed to driving impactful change in the DevOps space."