In: Computer Science
Linux project deployment Script
Create a script “setup.sh” to automate the deployment of a flask application. The script must install all software dependencies such as:
Python3
Pip3
Git
Use github to clone this repository.
Install the dependencies given in requirements.txt
Start the server by executing the following command “gunicorn wsgi:app”
requirements.txt
Click==7.0
Flask==1.0.2
Flask-Cors==3.0.7
Flask-JWT==0.3.2
Flask-SQLAlchemy==2.3.2
gunicorn==19.9.0
itsdangerous==1.1.0
Jinja2>=2.10.1
MarkupSafe==1.1.1
PyJWT==1.4.2
six==1.12.0
SQLAlchemy==1.3.1
werkzeug>=0.15.3
#!/usr/bin/env bash
#declare the constants
orgName="example"
reponame="example"
reqs ="Click==7.0
Flask==1.0.2
Flask-Cors==3.0.7
Flask-JWT==0.3.2
Flask-SQLAlchemy==2.3.2
gunicorn==19.9.0
itsdangerous==1.1.0
Jinja2>=2.10.1
MarkupSafe==1.1.1
PyJWT==1.4.2
six==1.12.0
SQLAlchemy==1.3.1
werkzeug>=0.15.3"
# update source list for packages and versions that can be installed
sudo apt-get update
#install python
sudo apt-get install -y python3.6 python3-pip python3.6-dev
#install GitHub
sudo apt-get install git-all
#clone repository using ssh -- need to setup ssh key for account
git clone [email protected]:$orgName/$reponame.git
echo "Cloning: [email protected]:$orgName/$reponame.git"
#change dir to newly cloned repo
cd $reponame
#create the requirement.txt file
echo "$reqs" > requirements.txt
#install all dependencies using requirements.txt
pip3 install -r requirements.txt
#Start the server by executing the following command
gunicorn wsgi:app
I added all the commands as per the requirements in the question, for cloning the repository SSH keys must be setup first for authentication. If you have any further question, feel free to comment on the answer. I will be happy to help.