Skip to content
This repository was archived by the owner on May 7, 2021. It is now read-only.

Setting Up Development Environment Guide

Stephen Li edited this page Mar 12, 2016 · 11 revisions

1. Install Tools

Linux

Note that these commands were written with Ubuntu/Linux Mint in mind since they use apt. If you use another distribution, you may need to find the equivalent packages and commands for your system.

# Install Python
sudo apt-get install -y python
sudo apt-get install -y python-pip
sudo apt-get install -y python-dev
sudo apt-get install -y libffi-dev # For compiling bcrypt

# Install Postgres
sudo apt-get install -y postgresql
sudo apt-get install -y python-psycopg2
sudo apt-get install -y libpq-dev

# Install Node
sudo apt-get install -y nodejs npm
sudo ln -s `which nodejs` /usr/bin/node

# Install redis
sudo apt-get install -y redis

OSX

# Install brew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH="/usr/local/bin:$PATH"
source ~/.bash_profile

# Ensure brew is up to date
brew update

# Install Python
brew install python

# Install Postgres
brew install postgresql

# Install npm
brew install npm

# Install redis
brew install redis

2. Install Project Dependencies

cd src-django/
pip install -r requirements.txt
cd src-backbone/
npm install -g gulp jshint browserify mocha
npm install

3. Setting up database

Linux

Enter the following commands into the terminal:

sudo -u postgres createuser --superuser sample_db_user
sudo -u postgres psql -c "ALTER USER sample_db_user WITH PASSWORD 'sample_db_password';"
sudo -u postgres createdb sample_db_name

Then export the required environment variables below. You may want to add these commands to your ~/.bashrc to save time in the future.

export DJANGO_SECRET_KEY='sample_secret_key'
export DJANGO_DB_NAME='sample_db_name'
export DJANGO_DB_USER='sample_db_user'
export DJANGO_DB_PASSWORD='sample_db_password'
export EMAIL_FROM='Sample Name <[email protected]>'
export EMAIL_HOST='smtp.example.com'
export EMAIL_HOST_USER='[email protected]'
export EMAIL_HOST_PASSWORD='sample_password'

OSX

Start the postgres server in a terminal by entering:

postgres -D /usr/local/var/postgres

Then enter these into a separate terminal:

sudo su _postgres
createuser --superuser sample_db_user

Inside the Postgres terminal enter:

\password sample_db_password

Once prompted for the password enter sample_db_password again and then exit with Ctrl+D. Finally enter:

createdb sample_db_name

Finally, export the required environment variables:

export DJANGO_SECRET_KEY='sample_secret_key'
export DJANGO_DB_NAME='sample_db_name'
export DJANGO_DB_USER='sample_db_user'
export DJANGO_DB_PASSWORD='sample_db_password'
export EMAIL_FROM='Sample Name <[email protected]>'
export EMAIL_HOST='smtp.example.com'
export EMAIL_HOST_USER='[email protected]'
export EMAIL_HOST_PASSWORD='sample_password'

4. Running backend and frontend

In one terminal window:

cd src-django
./manage migrate
./manage runserver

In another terminal window:

cd src-backbone
gulp debug

In a new terminal window, start redis:

redis-server

In order to have your local development send emails, start Celery:

celery --app=sanaprotocolbuilder.celery:app worker --loglevel=INFO

5. Extra Configurations

These are optional but highly recommended.

Git Hooks

cd scripts/
chmod +x setup_hooks.sh
./setup_hooks.sh

Clone this wiki locally