DEV Community

Cover image for "How to Automate Spring Boot Deployment with Shell Script & Vagrant (Step-by-Step for Beginners)"
SAFI-ULLAH SAFEER
SAFI-ULLAH SAFEER

Posted on

"How to Automate Spring Boot Deployment with Shell Script & Vagrant (Step-by-Step for Beginners)"

🎯 Level: Beginner-friendly

πŸ“‚ Project Repo: https://github.com/SAFI-ULLAHSAFEER/Shell-Script

πŸ› οΈ Why Shell Script Automation?

Automating application deployments saves time and reduces human errors. In this blog, I’ll walk you through deploying a Spring Boot WAR app inside a Vagrant-managed Ubuntu machine using a Shell Script. All actions are visualized step-by-step with real screenshots. Perfect for beginners in DevOps, scripting, or system setup!

πŸ“¦ Prerequisites

Installed: Git, Vagrant, VirtualBox

Basic knowledge of Linux terminal

A Spring Boot WAR file (included in the GitHub repo)

πŸ“ Step 1: Clone the Project

Open the VS code

Image description

Type the following command git clone https://github.com/SAFI-ULLAHSAFEER/Shell-Script

Image description

πŸ“‚ Step 4: Navigate to Your Spring Boot App Directory

Image description

Start the Vagrant Box

Image description

πŸ› οΈ This command will automatically create and configure a virtual Linux machine for you, .This command logs you into the virtual Ubuntu machine where everything will run.

Image description

As you can see the black console screen only we called it as a multi-user.target in linux.

Image description

Now Next Step is SSH Into the Machine

Image description

After that Navigate to Your Spring Boot App Directory
By default, Vagrant shares your local directory under /vagrant.

Image description

After that next step is Create setup.sh Script

Image description

Image description

Now the next step is to Make the Script Executable and Run

chmod +x setup.sh
sudo ./setup.sh

Image description

This will:

Update packages

Install Java and Tomcat

Deploy your WAR file

Restart Tomcat

Image description

Now the NeXT Step is Check the IP Address by running command:
ip a

Image description

The following ip address of machine will appear

Image description

Now the next Step is Access Your App in the Browser

Image description

then press enter and the following screen will appear

Image description

πŸš€ Congratulations! If everything workedβ€”you’ll see your Spring Boot app live!

Image description

Exit and Destroy the Vagrant Machine (Cleanup)
After verifying the app in the browser, clean up your VM:

exit
vagrant destroy

Image description

This command:

Logs out of the VM

Prompts you to confirm destroying the environment

Frees up system resources

Final Thoughts ❀️

This hands-on guide is your stepping stone into automation with shell scripting. Share this with your peers and drop your questions below. Happy scripting!

Top comments (1)

Collapse
 
kalsoom_ahmed_beaa4b9a88b profile image
Kalsoom Ahmed

Very well defined each step definitely trying on weekend πŸ‘πŸ‘