####Setup You'll need:
- Python 3.4 (2.7 should work as well)
- NodeJS >= 0.10
- Postgres
- Vagrant (optional)
-
Install system-level dependencies (you may omit some of these, per guidelines above):
brew install python3 node postgresql vagrant
(I've often had problems with Homebrew's postgres package - Postgres.app can be a good alternative.)
-
Run the following commands in psql to set up the Postgres database:
CREATE ROLE djangobase WITH LOGIN CREATEDB PASSWORD 'djangobase'; CREATE DATABASE djangobase;
-
Install Python dependencies with:
pip install -r reqs/dev.txt
-
Setup your
ansible/env_vars/secure.yml
file. It contains application secrets and third-party API credentials. An example file with secrets ommitted is atansible/env_vars/secure_safe.yml
. -
Set up the database with:
python manage.py syncdb
-
Check that setup was successful with:
python manage.py check
-
Start the local server with:
python manage.py runserver
####Tests You can run the project's test suite with:
python manage.py test
To view unit test coverage, install coverage
(pip install coverage
), then run:
coverage run --source=djangobase manage.py test
The project comes with a .travis.yml
file - if your repository is publicly available on GitHub, Travis CI can be easily configured to run the test suite on git push. Furthermore, Coveralls.io can be easily added to this setup as a test coverage reporting tool.
The continuous integration suite is configured to run against both Python 2.7 and 3.4.
####Deployment The code base includes Ansible roles for configuring a Linux server and deploying the project onto it.
The following command will execute the complete playbook on all of the hosts defined in ansible/inventory/prod
:
ansible-playbook ansible/deploy.yml
For testing purposes, you may use the included Vagrantfile to provision a test VM that approximates the production server. To deploy to Vagrant, run the following:
vagrant up
ansible-playbook -i ansible/inventory/vagrant ansible/deploy.yml
sudo echo "192.168.100.100 djangobase.local" >> /etc/hosts
and visit http://djangobase.local in your browser if the deploy is successful.
The project is currently deployed at djangobase.bjacobel.com.