Skip to content

hackcoderr/crud-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CRUD Application

Designed and deployed a web application for performing CRUD operations.

Structure

Let's try to understand the below crud application structure for deploying it.

  1. Install the terraform on your machine.
  2. Configure the terraform with AWS for provisioning the resources from AWS.
  3. Install Ansible, configure it with AWS, and set up your dynamic inventory.
  4. Install Docker on AWS Instance through Ansible.
  5. Install Jenkins on AWS Instance for CI/CD through Ansible.
  6. Configure Docker Swarm through Ansible.
  7. Create Dockerfile with PHP image and its dependencies.
  8. Create Jenkinsfile for CI/CD
  9. Push all the codes on GitHub
  10. Attach GitHub Repo with Jenkins for triggering the changes.
  11. Connect Docker Swarm nodes with Jenkins Server and Build Dockerfile using CI/CD.
  12. Create a docker-compose file for PHP and MySQL and mention docker-compose up -d in Jenkinsfile.
  13. 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

Terraform and AWS CLI Installation

Tested on:

RHEL centos amazon

Install and configure terraform and AWS CLI through script.

chmod +x bash/terra-aws-setup.sh
./bash/terra-aws-setup.sh

Provisioning AWS resources

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

Ansible Installation

Tested on:

RHEL centos ubuntu amazon

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.

Install Jenkins Server and Docker Swarm throgh Ansible

Go inside ./ansible/ and run below ansible playbook to install and configure Jenkins and Docker Swarm according.

Install Docker

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

Install Jenkins

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