Table of Contents
Goal
Goal of this project to create Docker Compose Stack to deploy simple Java application running in Containers 3-Tier Architecture.
Pre-Requisites
- Create AWS EC2 Instance in Public Subnet with any desired Instance Type
- Allow Port 80 in Security Group
- Add A Record in Route 53 Hosted Zone pointing to the EC2 Public IP.
- Apache Maven Build Artifact (.war)
- Install docker and run docker service
- Install docker-compose
- Java Source Code
Docker Compose Stack
MySQL
- Write Dockerfile to create custom MySQL container image by taking docker.io/mysql:8.0 as reference image from Docker Hub registry.
MYSQL_ROOT_PASSWORDENV MYSQL_DATABASEENV MYSQL_USERENV MYSQL_PASSWORD
App:
- Write Dockerfile to create custom Tomcat application container image by taking docker.io/amazonlinux as reference image from Docker Hub registry.
- Install Apache Tomcat 8.5
- Install unzip, vim, telnet, mysql client, JDK 11 packages
- Copy .war artifact to webapps
- Start Tomcat services on container runtime automatically.
Nginx
- Write Dockerfile to create custom Nginx container image by taking docker.io/amazonlinux as reference image from Docker Hub registry.
- Install Nginx server
- Install telnet
- Copy custom nginx.conf file with proxy_pass rule to forward the traffic to the app container.
Compose Stack
- Write Docker Compose Stack to Build and Run the Nginx, MySQL, App containers.
- Deploy the applications into common single Bridge network
- Supply the values to MySQL environment variables
- Specify dependencies of each containers.
Validation
- Run “docker-compose build” command to verify if container images are getting created
- Run “docker-compose up -d” command to verify if all containers are running
- Login to Nginx container shell and check App port is reachable
- Login to App container shell and check MySQL port is reachable
- Browse the application from public internet browser to verify the application is accessible
Destroy
- Once the project setup completed do not forget to clean up resources to avoid the billing for your test environment
- Run “docker-compose down” command to retire all containers
- Terminate EC2 instance from AWS Console.
Still if you are confident to deploy the compose stack, repeat the steps again. Good Luck!!
© Edwiki Trainings – Click HERE If you are interested to learn more on Cloud & DevOps stack.
1 comment
Hello
hOW TO CONFIGURE THE nGINX PART CAN YOU PLEASE SUGGEST.
i HAVE DEPLOYED app IMAGE AND db IMAGE AS A POD
i HAVE CREATED dATABASE TABLE AND 1 ROW INSIDE THAT EPLOYEE TABLE
i AM ABLE TO CONNECT FROM app POD TO db POD
suppose my APP-image pod ip is 10.244.1.213
how i will set to a poxu_Pass rule in nginx.conf
can you please share nginx.conf