This project demonstrates the containerization of a Java-based application using Docker. The architecture includes an Nginx frontend, a Tomcat-based application server, a MySQL backend, and additional services such as RabbitMQ and Memcached. The setup involves multi-stage Docker builds to efficiently manage the application image and reduce its size. The Docker engine runs on an AWS EC2 instance of the t2.small type.
-
Frontend: Nginx
- The Nginx server serves as the frontend for the application.
-
Application Server: Tomcat
- The backend Java application is deployed on an Apache Tomcat server. A multi-stage Docker build is used for the application server:
- Stage 1: Builds the artifact.
- Stage 2: Sets up the Tomcat application server using the built artifact.
- The backend Java application is deployed on an Apache Tomcat server. A multi-stage Docker build is used for the application server:
-
Backend: MySQL
- The database backend is handled by a MySQL server. A custom Dockerfile was written for MySQL to accommodate the specific configuration needs of the application.
-
Additional Services:
- RabbitMQ: Used for message queuing.
- Memcached: Used for caching.
- Both RabbitMQ and Memcached utilize standard Docker images from Docker Hub.
- Source: Write Dockerfiles for Nginx, Tomcat (with multi-stage build), and MySQL. Use standard images for RabbitMQ and Memcached.
- Build: Perform a Docker build using multi-stage builds to create efficient images for Nginx and Tomcat.
- Test: Use Docker Compose to test the entire application stack locally.
- Store: Push the built images to Docker Hub or your private registry.
- Docker
- Docker Compose
- AWS EC2 instance (t2.small)
-
Launch an EC2 Instance
- Launch an EC2 instance of
t2.smalltype. - Install Docker Engine on the instance.
- Launch an EC2 instance of
-
Clone the Repository
git clone cd vprofile-project git checkout containers -
Build and Run the Docker Containers
docker compose up
-
Access the Application
- The application should now be accessible through the Nginx frontend at
http://<EC2-Instance-Public-IP>:8080.
- The application should now be accessible through the Nginx frontend at
-
Stop the Containers
docker compose down
-
View Logs
docker compose logs -f

