diff --git a/.env.test b/.env.test index 58f63bd2e..45f46888e 100644 --- a/.env.test +++ b/.env.test @@ -1,6 +1,6 @@ DEBUG=true SECRET_KEY='tests' -DATABASE_URL='postgresql:///opencraft-test' +DATABASE_URL='postgres://localhost/opencraft' HUEY_ALWAYS_EAGER=true OPENSTACK_USER='test' OPENSTACK_PASSWORD='pass' diff --git a/.gitignore b/.gitignore index 69f0ee8a2..c012724c9 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,6 @@ target/ # Local configuration .env .env.integration + +# Vagrant +.vagrant/ diff --git a/README.md b/README.md index 7065e506b..c7bc79d9e 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,35 @@ OpenCraft Install ------- +### Vagrant install + +You can use [vagrant][] to set up a virtual machine for local development and +testing. This is useful to keep your development environment isolated from the +rest of your system. + +First, install [virtualbox][] and [vagrant][]. Then run: + + vagrant up + +This will provision a virtual machine running Ubuntu 14.04, set up local +postgres and redis, install the dependencies and run the tests. + +Once the virtual machine is up and running, you can ssh into it with this +command: + + vagrant ssh + +Vagrant will set up a virtualbox share mapping your local development directory +to `/vagrant` inside the virtual machine. Any changes you make locally will be +reflected inside the virtual machine automatically. + +Vagrant will map port 5000 inside the virtual machine to port 5000 on the host, +so you can access the development server using your web browser. + + +### Local install + +If you prefer not to install vagrant, you can install OpenCraft manually. Instructions based on Ubuntu 14.04. Install the system package dependencies & virtualenv: @@ -33,8 +62,14 @@ $ pip install -r requirements.txt Configure --------- -Create an `.env` file at the root of the repository or set environment variables, customizing the -settings from `opencraft/settings.py` which are loaded via `env()`. +Honcho will set up environment variables defined in the `.env` file at the root +of your repository. If you are using vagrant for development, a basic `.env` +file will already have been created for you, but you will need to add +credentials for third-party services manually in order to run the development +server or the integration tests. + +The environment variables in `.env` customize the settings from +`opencraft/settings.py` which are loaded via `env()`. Migrations @@ -141,9 +176,9 @@ $ make test_unit $ make test_integration ``` -Note that the integration tests aren't run by default, as they require a working OpenStack cluster -configured. To run them, create a `.env.test` file - your development environment is likely a good -starting point: +Note that the integration tests aren't run by default, as they require a working +OpenStack cluster configured. To run them, create a `.env.integration` file - +your development environment is likely a good starting point: ``` $ ln -s .env .env.integration @@ -168,3 +203,7 @@ You can also access the Django `manage.py` command directly, using honcho to loa ``` $ honcho run ./manage.py config ``` + + +[virtualbox]: https://www.virtualbox.org/ +[vagrant]: https://www.vagrantup.com/ diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 000000000..67d0ce6fa --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,61 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# This script provisions a vagrant development environment with local +# postgres and redis servers for development and testing. +PROVISION = <