Designed and deployed a web application for performing CRUD
operations.
Let's try to understand the below crud application structure for deploying it.
- Install the
terraform
on your machine. - Configure the terraform with
AWS
for provisioning the resources from AWS. - Install
Ansible
, configure it with AWS, and set up yourdynamic inventory
. - Install
Docker
on AWS Instance through Ansible. - Install
Jenkins
on AWS Instance for CI/CD through Ansible. - Configure
Docker Swarm
through Ansible. - Create
Dockerfile
with PHP image and its dependencies. - Create
Jenkinsfile
for CI/CD - Push all the codes on GitHub
- Attach
GitHub
Repo with Jenkins for triggering the changes. - Connect Docker Swarm nodes with Jenkins Server and Build Dockerfile using
CI/CD
. - Create a docker-compose file for
PHP
andMySQL
and mention docker-compose up -d in Jenkinsfile. - Now your CRUD application is ready for use.
Now perform all the steps one by one and follow mentioned staff according. So first, clone this repository in your machines where you need it.
git clone https://github.com/hackcoderr/crud-app.git
Tested on:
Install and configure terraform and AWS CLI through script.
chmod +x bash/terra-aws-setup.sh
./bash/terra-aws-setup.sh
Provision AWS Resources like EC2 instance VPC component etc which we will have need to deploy this application.
Create IAM User for getting accees and secret key which we will use to estabish the connection b/w terraform and AWS Account.
Run the below command to set your aws profile which we will use in terraform code so give your access and secret key after running this command.
aws configure --profile <profile-name>
# aws configure --profile hackcoderr
Go inside ./terraform
folder and run the below commands to get required AWS resources.
cd terraform/
terraform init
terraform apply --auto-approve
Tested on:
Run the below command to install and configure Ansible.
sudo yum install python3 git -y
git clone https://github.com/hackcoderr/ansible-setup.git
cd ansible-setup/
python3 script.py
For more information, Please go through Ansible Setup Repository.
Go inside ./ansible/
and run below ansible playbook to install and configure Jenkins and Docker Swarm according.
Path: ./ansible/docker/
Before running playbook please changes your hosts
according to your instance tag
.
- hosts: <instance_tag_name>
eg:
- hosts: tag_Name_DockerNode
Run the ansible playbook to install docker swarm.
ansible-playbook docker.yml
Path: ./ansible/jenkins/
Before running playbook please changes your hosts
according to your instance tag
.
- hosts: <instance_tag_name>
eg:
- hosts: tag_Name_JenkinsNode
Run the ansible playbook to install docker swarm.
ansible-playbook install-jenkins.yml