Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions helper-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## Building and Running on Dev Environment
+ Clone the repo and check python and pip version on machine using `python --version` and `pip --version`
+ Install virtualenv on machine using `pip install virtualenv` and verify using `virtualenv --version`
+ Configure virtualenv for project
- Change into project subdirectory using `cd service`
- Create a python virtual environment for the project using `virtualenv venv`
- Load virtual environment using `source venv/bin/activate`
- Install project dependencies using `pip install -r ../requirements.txt`
- You can unload virtual environment using `deactivate`
+ Create a file **api.env** with following content:
`export SECRET_KEY='<API-SECRET-KEY>'`
`export DEVELOPMENT_DATABASE_URL='sqlite:///auth.db'`
`export ENV='DEVELOPMENT'`
+ Run on dev environment using `bash start-dev.sh`


## Running on Stage Environment
+ Install PostgreSQL on machine using `sudo apt-get install postgresql` and verify using `psql --version`
+ Configure PostgreSQL on local machine.
- Login to postgres console using `sudo -u postgres psql`
- Create role using `CREATE USER <POSTGRES_USER> WITH PASSWORD '<POSTGRES_PASS>'`
- Create DB using `CREATE DATABASE <POSTGRES_DB>`
- Grant permissions using `GRANT ALL PRIVILEGES ON DATABASE <POSTGRES_DB> TO <POSTGRES_USER`
- Close postgres console using `\q`
+ Add the following line to the file **api.env**
`export STAGE_DATABASE_URL='postgresql+psycopg2://<POSTGRES_USER>:<POSTGRES_PASS>@localhost/<POSTGRES_DB>'`
+ Run on stage environment using `bash start-stage.sh`

## Running on Production Environment
+ Install Heroku CLI on machine using `curl https://cli-assets.heroku.com/install-ubuntu.sh | sh` and verify using `heroku --version`
+ Confiugre Heroku deploy on local machine.
- Login to heroku account using `heroku login`
- Create heroku app using `heroku create auth-api-flask`
- Set buildpack for the app using `heroku buildpacks:set heroku/python`
- Create Procfile with the content as
`web: cd service && gunicorn app:app`
+ Login to Heroku platform and add `Heroku Postgres` as an add-on.
+ Modify config vars as follows:
`PRODUCTION_DATABASE_URL = <HEROKU-PROVIDED-URL>`
`ENV = PRODUCTION`
`SECRET_KEY = <API-SECRET-KEY>`
+ Push the project to Heroku platform using `git push heroku master`
+ Configure aut-deploy from GitHub hooks.