Skip to content

rochapps/pcs

Repository files navigation

PCS (Primate Comparative Socioecology)

Below you will find basic setup and deployment instructions for the pcs project. To begin you should have the following applications installed on your local development system:

A note on NodeJS 4.2 for Ubuntu users: this LTS release may not be available through the Ubuntu repository, but you can configure a PPA from which it may be installed:

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

You may also follow the manual instructions if you wish to configure the PPA yourself:

https://github.com/nodesource/distributions#manual-installation

Django version

The Django version configured in this template is conservative. If you want to use a newer version, edit requirements/base.txt.

Getting Started

First clone the repository from Github and switch to the new directory:

$ git clone git@github.com:[ORGANIZATION]/pcs.git
$ cd pcs

To setup your local environment you can use the quickstart make target setup, which will install both Python and Javascript dependencies (via pip and npm) into a virtualenv named "pcs", configure a local django settings file, and create a database via Postgres named "pcs" with all migrations run:

$ make setup
$ workon pcs

If you require a non-standard setup, you can walk through the manual setup steps below making adjustments as necessary to your needs.

To setup your local environment you should create a virtualenv and install the necessary requirements:

# Check that you have python3.4 installed
$ which python3.4
$ mkvirtualenv pcs -p `which python3.4`
(pcs)$ pip install -r requirements/dev.txt
(pcs)$ npm install

Next, we'll set up our local environment variables. We use django-dotenv to help with this. It reads environment variables located in a file name .env in the top level directory of the project. The only variable we need to start is DJANGO_SETTINGS_MODULE:

(pcs)$ cp pcs/settings/local.example.py pcs/settings/local.py
(pcs)$ echo "DJANGO_SETTINGS_MODULE=pcs.settings.local" > .env

Create the Postgres database and run the initial migrate:

(pcs)$ createdb -E UTF-8 pcs
(pcs)$ python manage.py migrate

If you want to use Travis to test your project, rename project.travis.yml to .travis.yml, overwriting the .travis.yml that currently exists. (That one is for testing the template itself.):

(pcs)$ mv project.travis.yml .travis.yml

Development

You should be able to run the development server via the configured dev script:

(pcs)$ npm run dev

Or, on a custom port and address:

(pcs)$ npm run dev -- --address=0.0.0.0 --port=8020

Any changes made to Python, Javascript or Less files will be detected and rebuilt transparently as long as the development server is running.

Deployment

The deployment of requires Fabric but Fabric does not yet support Python 3. You must either create a new virtualenv for the deployment:

# Create a new virtualenv for the deployment
$ mkvirtualenv pcs-deploy -p `which python2.7`
(pcs-deploy)$ pip install -r requirements/deploy.txt

or install the deploy requirements globally:

$ sudo pip install -r requirements/deploy.txt

You can deploy changes to a particular environment with the deploy command:

$ fab staging deploy

New requirements or migrations are detected by parsing the VCS changes and will be installed/run automatically.