Objective: To demonstrate the deployment of a multi-tier application using Docker Compose, including configuring public IP addresses and setting up necessary security group rules for accessing the frontend, API, and database services.
Real-time Scenario: A user is tasked to deploy a multi-tier application on a cloud-based virtual machine using Docker Compose. After installing Docker, Docker Compose, and Git, they clone the application repository and update configuration files with the machine's public IP to ensure proper communication between the frontend, API, and backend components. Post these updates, the user runs docker compose to bring up the application, adjust the security group settings to allow traffic on specific ports (8080, 5000), and verify the deployment by accessing the application via the public IP. This confirms that all components are accessible and functional.
- Docker: Docker is a platform that allows users to package, ship, and run applications within lightweight, isolated environments called containers, ensuring consistent execution across different systems.
- Docker Compose: It is a tool used for defining and managing multi-container Docker applications, using a YAML file to simplify the orchestration services. It specifies the Services, Networks, Volumes, etc. required for the application.
- Git: A version control system used to clone the application repository from GitHub, enabling easy access to the code and management of code.
- AWS EC2-Instance: An Amazon EC2 instance is a virtual server, or virtual machine, within Amazon's Elastic Compute Cloud (EC2) service, allowing users to run applications on the AWS cloud.
3-Tier-Application details:
- Frontend (Web) – running on Node.js environment with npm package manager.
- Backend (API) – running on Node.js environment with npm package manager.
- Database (DB) – running Mongo DB program.
The name of the Application is “Wanderlust - Your Ultimate Travel Blog”.
3-Tier Application Architecture
- Create an EC2 Instance in AWS Cloud Infrastructure.
- To Clone 3-Tier-Application Source Code from Github.
- To create Docker file for frontend, backend and to create Docker-Compose file for complete application.
- To update the environment files (.env.sample) for correct host URL.
- To update the security group settings of Host Machine (EC2 Instance) to allow the traffic on specific ports on which app services are running.
- Now all the settings are complete, perform the docker-compose up command to run the containers and bring up all the services for real-time usage.
- To verify the deployment of 3-tier-application by accessing the application via public-ip of Host machine.
Clone 3-Tier-Application Source Code from Github
update the security group settings of Host Machine (EC2 Instance) to allow the traffic on specific ports on which app services are running
All the three containers for frontend, backend and mongo DB got created successfully:
To verify the deployment, try access the web-app URL.
On any web browser, hit the URL: http://54.166.95.96:5173/
Now the Application is accessible, please find below the screenshot:
As per the requirement of the Project: the Deployment of Multi-Tier Application using Docker Compose is performed successfully!