Introduction

In this project, I aimed to deploy a Java application stack (Nginx, Tomcat, MySQL) using Docker-Compose. The project objective was to create a complete stack of Nginx, Tomcat, and MySQL in a way that the application would run smoothly in the Docker environment. The Java login application source code was committed to a Bitbucket repo, and necessary modifications were made to the application.properties file for connectivity with the MySQL database.

 

Implementation:

  • Java application source code was built, and the artifact (.war) was kept ready.
  • Docker-Compose YAML file was written to deploy the Nginx, Tomcat, and MySQL containers.

Nginx:

  • An Nginx container was customized using the “docker.io/nginx” image, and the Nginx configuration file (nginx.conf) was volume-mapped to proxy the requests to the Tomcat container.
  • Port 80 was exposed.

Tomcat:

  • A Tomcat container was customized using the “docker.io/amazonlinux” image, and the tomcat-users.xml file and .war artifact were volume-mapped to serve the Java login application.
  • Port 8080 was exposed, and necessary Java, mysql, and telnet packages were installed.

MySQL:

  • A MySQL container was customized using the “docker.io/mysql” image, and environment variables were added to set the database name and passwords.
  • Port 3306 was exposed, and the Table Schema was created on container startup. The README.md file of the Bitbucket repo was updated with the Table Schema details for the Login application’s compatibility.

Validation:

  • The containers were checked for their running status and healthiness.
  • The Tomcat container was logged into and MySQL’s access was verified using the “mysql” client CLI.
  • A hosted zone was created in AWS Route 53, and an A record was added pointing to the EC2 instance’s Elastic IP.
  • The application was verified to be accessible using a public internet browser.

Conclusion:

The Docker-Composed Java application stack was successfully deployed, and the application was validated for its smooth running. The Nginx, Tomcat, and MySQL containers were customized and configured to meet the requirements of the Java login application. This project demonstrated my proficiency in deploying and running applications in the Docker environment.

 

Technology / Services

  • Bitbucket
  • Maven
  • Tomcat
  • Nginx
  • MySQL