DEPLOYMENT OF PYTHON WEB APPLICATION USING AWS
DEPLOYMENT OF PYTHON WEB APPLICATION USING AWS

DEPLOYMENT OF PYTHON WEB APPLICATION USING AWS

Hello Everyone !!

this the project on DEPLOYMENT OF PYTHON WEB APPLICATION USING AWS -- SocialPrachar.com

first I am going to explain what is python, pip, and flask

PYTHON

Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis

PIP

Pip is a package manager for Python that allows you to install additional libraries and packages that are not part of the standard Python library such as the ones found in the Python Package Index.

FLASK

Flask is a web framework that provides libraries to build lightweight web applications in python. It is developed by Armin Ronacher who leads an international group of python enthusiasts (POCCO). It is based on WSGI toolkit and jinja2 template engine. Flask is considered as a micro framework.


MANUAL DEPLOYMENT

Deploying python application manually by using AWS resources.

Step-1: - Launch a EC2 Instance (ubuntu) by adding ports 22,80&8080 in security group.

Step-2: - Connect to the Instance with SSH key.

Step-3: - Update your ubuntu machine with following commands

Commands: Sudo apt update

???????????????????Sudo apt-get full upgrade -y

No alt text provided for this image

Step-4: - Install required package/tools that required for project deployment.

???? Command: Sudo apt-get install python3-pip

No alt text provided for this image

?Clone the project code from the git hub into your machine.

???? Command: Git clone https://github.com/afzal-in/car_prediction.git

No alt text provided for this image

?Step-6: - Go to the source directory by using cd command.

????Step-7: - Install requirements package??

Command: pip install -r requirements.txt

No alt text provided for this image

?Step-8: - Change app.py file with vi command. Add 0.0.0.0 host to host from anywhere with 8080??port.

No alt text provided for this image

Step-9: - Run the flask server by executing below command

Command: python3 app.py

No alt text provided for this image

Step-10: - Execute Screen -m -d python3 app.py to run application continuously.

??Step-11: - Browse the public Ip of instance with given port to check output.


OUTPUT: -

No alt text provided for this image

DEPLOYMENT THROUGH JENKINS


???Step-1: - Launch a EC2 Instance (ubuntu) by adding ports 22,80&8080 in security group.

???Step-2: - Connect to the Instance with SSH key.

???Step-3: - Install git in the instance.

Command: Sudo yum install git -y

??Step-4: - Install Jenkins in the instance.

Command:?

? sudo yum update –y

? sudo wget -O /etc/yum.repos.d/jenkins.repo \

https://pkg.jenkins.io/redhat-stable/jenkins.repo

? sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

? sudo yum upgrade

? sudo amazon-linux-extras install java-openjdk11 -y

? sudo yum install jenkins -y

? sudo systemctl enable Jenkins

? sudo systemctl start Jenkins

? sudo systemctl status Jenkins

??Step-5: - Connect to the Jenkins server by browsing public Ip of instance with 8080 port.

??Step-6: - Setup Jenkins account by adding credentials.

??Step-7: - Create a new job by selecting freestyle project and provide project description

No alt text provided for this image


??Step-8: - Select “Git” as a source code repository. Provide repo URL and credentials.

Step-9: - Select “Execute shell” in Build Steps and write commands.

Commands:

? Sudo yum install python3-pip -y

? Pip install -r requirements.txt

? Screen -m -d python3 app.py

No alt text provided for this image

??Step-10: - Apply and save the project configurations.

?Step-11: - Build the project by clicking “Build Now”.

No alt text provided for this image

?Step-12: - Check the output by browsing the public Ip of instance with provided port.

No alt text provided for this image

DEPLOYMENT THROUGH TERRAFORM

Step-1: - Launch EC2 instance and connect to the instance with SSH key.

?Step-2: - Install Terraform in the instance.

Commands:?

? sudo yum install -y yum-utils

? sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo

? sudo yum -y install terraform

?Step-3: - Create a Directory with mkdir command and go inside the directory.

?Step-4: - Initialize directory with terraform Init command.

?Step-5: - Create a provider file by using touch command with .tf extension.

Commands: touch provider.tf

?Step-6: - provide account credentials in provider.tf file by using vi command.

Command: vi provider.tf

No alt text provided for this image

?Step-7: - Create a file for VPC (vpc.tf).

No alt text provided for this image

?Step-8: - Create a file for subnet (subnet.tf).

No alt text provided for this image

?Step-9: - Create a file for Route Table (routetable.tf).

No alt text provided for this image

?Step-10: - Create a file security group (securitygrp.tf).

No alt text provided for this image

?Step-12: - Create a file for AWS EC2 instance(ec2.tf) and write a script for EC2 Instance.

No alt text provided for this image

?Step-11: - Create a file for user data with .sh extension (userdata.sh).?

No alt text provided for this image

?Step-13: - Execute terraform fmt, terraform validate, terraform plan and terraform apply command.

No alt text provided for this image

?Step-14: - Check the output by browsing public Ip of instance with given port.

No alt text provided for this image

DEPLOYMENT THROUGH JENKINS USING TERRAFORM SCRIPT

Deploying python web application through Jenkins by using terraform script.

Create data.sh file and give below commands:

#!bin/bash

Sudo yum install git -y?

Sudo yum install -y yum-utils

Sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo

Sudo yum?install terraform -y

Sudo git clone https://github.com/afzal-in/python-tf.git

???????cd car-prediction

Terraform init

Terraform plan

Terraform apply –auto-approve

Step-1: - Launch a EC2 Instance by giving 8080 port and connect to the instance by using SSH key.

Step-2: - Install git in Instance.

Command: sudo yum install git -y

Step-3: - Install Jenkins in Instance by executing installation commands.

Step-4: - Connect to the Jenkins server by browsing public Ip of instance with 8080 port.

Step-5: - Setup Jenkins account by adding credentials.

Step-6: - Create a new job by selecting freestyle project and provide project description.

Step-7: - Select “Git” as a source code repository. Provide userdata.sh repo URL and credentials.

No alt text provided for this image

?Step-8: - Select “Execute shell” in Build Steps and write commands.

Commands:?

Sudo chmod +x ./userdata.sh

Sudo ./userdata.sh

No alt text provided for this image

?Step-9: - Build the project by clicking “Build Now”.

Step-10: - Check the console output to see the output.

Step-11: - Browse public Ip of instance with provided port number to see the python web application.

No alt text provided for this image
No alt text provided for this image

?output

No alt text provided for this image


What is Webhook?

A webhook enables third-party services like GitHub to send real-time updates to an application. Updates are triggered by an event or an action by the webhook provider like push to a repository, any commit to a code or pull request creation.

What is POLLSCM?

Poll SCM?polls the SCM periodically for checking if any changes or any new commits were made to the code and shall build the project if any new commits were pushed since the last build.

What is Build Periodically?

Build Periodically is process where we can set a time so that after every desired time the project will build automatically whether new changes or commits are happened or not

In the end I would like to thanks Amar M. sir Mahesh Babu Channa sir for providing me such an environment to learn and upskill myself in tech world.

A Special thank to EDUBILLI ANIL KUMAR sir

?




?




?




?


要查看或添加评论,请登录

MOHAMMED AFZAL的更多文章

  • BUILDING MAVEN PROJECT USING JENKINS

    BUILDING MAVEN PROJECT USING JENKINS

    Hello Everyone !! this the project on BUILDING MAVEN PROJECT USING JENKINS --SocialPrachar.com SocialTek.

    2 条评论
  • CREATING AWS INFRASTRUCTURE BY TERRAFORM

    CREATING AWS INFRASTRUCTURE BY TERRAFORM

    I Learn new things in the project. our instructor Amar M sir explain the what is the importance of terraform .

  • IMPORTANCE OF LINUX COMMNADS

    IMPORTANCE OF LINUX COMMNADS

    What is Linux ? Linux is an open-source operating system that serves as the foundation for many different types of…

社区洞察

其他会员也浏览了