Created
March 21, 2018 09:18
-
-
Save code-sleuth/ed08d73332e334bb624778c9f1aa66eb to your computer and use it in GitHub Desktop.
set up my flask api on aws instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| sudo apt-get update | |
| sudo apt-get install python3 python3-pip postgresql postgresql-contrib nginx virtualenv | |
| mkdir ~/cp3 | |
| cd ~/cp3 | |
| virtualenv --python=python3 venv | |
| git clone https://github.com/code-sleuth/yummy-recipes-api.git yummy-api | |
| cd yummy-api | |
| touch .env | |
| sudo cat<<EOF > ./.env | |
| source ~/cp3/venv/bin/activate | |
| export FLASK_APP='main_app.py' | |
| export SECRET='i wont tell if you dont' | |
| export APP_SETTINGS='development' | |
| export DATABASE_URL='postgres://postgres:postgres@postgres-instance.c12tfpvxgguu.eu-west-2.rds.amazonaws.com/yummy_api' | |
| export TEST_DB_URL='postgres://code:inetutils@localhost/test_db' | |
| EOF | |
| cd ~/cp3 | |
| ls | |
| source ~/cp3/venv/bin/activate | |
| pip install autoenv | |
| sudo cat<<EOF >> ~/.bashrc | |
| # autoenv | |
| source `which activate.sh` | |
| EOF | |
| # nginx | |
| # remove default configuaration rule file | |
| sudo rm /etc/nginx/sites-enabled/default | |
| # create symlink | |
| sudo ln -s /etc/nginx/sites-available/app /etc/nginx/sites-enabled/app | |
| # edit rule | |
| sudo bash -c 'cat > /etc/nginx/sites-available/app <<EOF | |
| server { | |
| location / { | |
| proxy_pass http://127.0.0.1:8000; | |
| } | |
| } | |
| EOF' | |
| # restart nginx server | |
| sudo /etc/init.d/nginx start | |
| sudo /etc/init.d/nginx restart | |
| source ~/.bashrc | |
| cd ~/cp3/yummy-api | |
| pip3 install -r requirements.txt | |
| gunicorn main_app:app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment