Code related to the «Scrum vu des petites tranchées» talk to be given at Paris-Web 2012.
Clone the project:
$ git clone https://github.com/prswb/prswb.git
$ cd prswb
Create a new virtualenv in ./.env
and enable it:
$ virtualenv --no-site-packages `pwd`/.env
$ source .env/bin/activate
Install dependencies:
$ pip install -r requirements-dev.txt
To launch a local dev webserver instance:
$ export UXPERIMENT_ENV=dev
$ python manage.py runserver
Validating models...
0 errors found
Django version 1.4.1, using settings 'uxperiment.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Head to http://127.0.0.1:8000/
, profit.
This django project has a settings/
directory having a setting module per environment:
settings/
|- base.py # common shared settings
|- dev.py # dev settings
|- production.py # production settings (hosting platform yet to be determined)
|- staging.py # staging (hosted on heroku)
|- test.py # travis settings
Eventually, custom settings may be stored in a settings/local.py
module.
The UXPERIMENT_ENV
environment variable will set the specific settings module
to load. To run the local webserver against a given environment:
$ UXPERIMENT_ENV=test python manage.py runserver
If you intend to work always with a given environment within the project virtualenv:
$ echo 'export UXPERIMENT_ENV=dev' >> .env/bin/postactivate
$ echo 'export unset UXPERIMENT_ENV' >> .env/bin/postdeactivate
The staging is hosted on Heroku and reachable at http://aqueous-mountain-3105.herokuapp.com/.
Note: You'll have to download and install the Heroku Toolbelt in order to manage some of the remote deployment procedures detailed below.
Your git user must have push
privileges on the heroku repository. You must also
provide your SSH public key to the admin account of the uxperiment
project.
Once done, add this section to the .git/config
of your local clone of the repo:
[remote "heroku"]
url = git@heroku.com:aqueous-mountain-3105.git
fetch = +refs/heads/*:refs/remotes/heroku/*
To push and deploy to heroku:
$ git push heroku master
After a push, Heroku will load the packages defined in the requirements.txt
file.
This file also contains packages for postgres
and gunicorn
.
At the end of the process, the Procfile
will be used by Heroku to start the server.
To tell Heroku to use the staging settings module:
$ heroku config:set DJANGO_SETTINGS_MODULE=uxperiment.settings.staging
The staging
settings module uses environment variables to configure the platform;
to set them you have to use the heroku config:add
command:
$ heroku config:add VARIABLE=VALUE
To run South migrations:
$ heroku run 'python manage.py migrate'
To tail the logs:
$ heroku logs --tail
The .travis.yml
file at the root of the repository contains the required configuration.