Skip to content
Carl Marshall edited this page May 17, 2015 · 7 revisions

Overall setup

The plan is to have a CI setup, with local development done by Carl in Didcot, pushing changes to the GitHub COPE repository, which will link to a Travis CI environment, and that in turn will link to a preview site running on my web server, before finally having a production server to push the live results to.

Setup progress:

  1. Local Dev setup - see below
  2. GitHub COPE repository - see this site. Mostly done.
  3. Travis CI - not yet, need the admin access to enable a link across. May not be an option easily for this being a private project. Need to investigate.
  4. Preview Site - not done.
  5. Production Site - no clue as to where that will be. Can be investigated after we get the preview site working.

Local Dev Setup

Key technologies:

  • Language: Python 2.7 (considering doing a 3.3 build later)
  • Core Framework: Django 1.8
  • UI Framework: Bootstrap 3.3
  • Datastore: SQLite3 initially, then onto Postgres 9

Locally developing on Mac OS X 10.10.3, using PyCharm for my IDE, VirtualEnv for project isolation, Homebrew for Postgres and non-python package management.

Previous (early example) work was done on a Windows 7 Virtual Machine, using VS2013 and C#, ASP.net, MVC5 & EF6. Dropped that in favour of the more flexible and faster working afforded by python development.

Preview Site

Based loosely on standard practice, plus [http://michal.karzynski.pl/blog/2013/09/14/django-in-virtualenv-on-webfactions-apache-with-mod-wsgi/]

Webfaction hosted, Control Panel actions:

  1. Create DNS entry (wp4.cm13.net)
  2. Create mod_wsgi application (mod_wsgi 4.4.11/Python 2.7 as wp4_django)
  3. Create symbolic link application (wp4_static, pointed at /webapps/wp4_django/static/)
  4. Create website with wp4_django at /, and wp4_static at /static/

CLI actions:

  1. ssh into account home. cd ~/webapps/wp4_django/
  2. rm -rf htdocs/ - remove the redundant htdocs folder
  3. mkvirtualenv wp4_20150514 - create the the virtual environment for the hosting
  4. touch ~/.virtualenvs/wp4_20150514/lib/python2.7/sitecustomize.py - to make pip use the local environment only
  5. Deactivate and start again (workon wp4_20150514)
  6. git clone git@github.com:AllyBradley/COPE.git to get the codebase
  7. cd COPE to get into the repository
  8. git checkout testing to get to the relevant branch
  9. pip install -r deploy/requirements.txt to get the libraries installed. Results in: Successfully installed Django psycopg2 docutils django-dbbackup ipython pysftp paramiko pycrypto ecdsa
  10. cp apache2/conf/httpd.conf apache2/conf/httpd.conf.orig to backup the template config
  11. ln -s ../../.virtualenvs/wp4_20150514/lib/ ./lib to make the local packages available in the near python path
  12. vi apache2/conf/httpd.conf -- see example below
  13. cd COPE/src/wp4/wp4/ so that we can go edit the project's settings
  14. cp settings_local.py.template settings_local.py
  15. vi settings_local.py -- see example below
  16. ../../../../apache2/bin/restart restart the apache instance to load all the new settings
  17. cd .. to the project root, so we can work with django management

Python actions (also cli): (NB: "pm" is an alias for "python manage.py")

  1. pm check - should produce zero issues
  2. pm migrate; pm createsuperuser to setup the database and the admin account
  3. ../../../apache2/bin/restart
  4. pm loaddata hospitals and pm loaddata persons to add the fixture data in

And lo there is a test site active.

Clone this wiki locally