Back to Install Table of Contents
Try this method if you want to develop on WeVoteServer locally, can use Vagrant with VirtualBox on your local machine, and don't want to or can't run Ansible host (this is especially for Windows users).
You'll end up with a prebuilt Vagrant box that's the same as if you have built the We Vote Ansible/Django/Vagrant project from scratch. For further documentation on what's installed, see that project's README.
Following these instructions, you will
- Check out the WeVoteServer codebase to a directory
- Create a Vagrant directory at the same level
- Download a prebuilt Vagrant box and Vagrantfile
- Import and start the Vagrant box
- Continue with the WeVoteServer setup instructions
git clone
the WeVoteServer project (or your fork of it). We're going to assume that this lives at /path/to/WeVoteServer
.
Create a directory at /path/to/WeVote-Vagrant
. The name isn't important, but the location is: this setup assumes it's in the same parent directory as the WeVoteServer code base.
Download the prebuilt Vagrant box to /path/to/WeVote-Vagrant
.
Download the Vagrantfile to the same directory.
You'll only need to import the box the first time you run it. From /path/to/WeVote-Vagrant
, run
vagrant box add --name wevote-imported wevote-server.latest.box
When that is done, you can start as you normally do:
vagrant up
You should start with this Django env vars file. It's missing secrets and other API keys for service integrations, but it will enable the Django app to start and run. Copy the file to WeVoteServer/config/environment_variables.json
.
After this, restart the Django app so that it reloads these variables. To do this:
- From
/path/to/WeVote-Vagrant
, runvagrant ssh
. This logs you into the Vagrant box. - Run
sudo supervisorctl restart wevoteserver
. This forces Gunicorn, the app server, to restart.
Note the URL specified for the API server in those env vars: https://localhost:8889/ Try this after you restart Gunicorn.
From here, you should be able to continue with the app setup instructions.
The application directory WeVoteServer
that's mounted from your host machine into Vagrant will be owned by the ubuntu
user. So, when you want to run Django commands such as migrate
, you'll need to do that (a) as ubuntu
and (b) within the virtualenv
. To do this:
- From the directory containing your Vagrantfile:
vagrant ssh
- Now you're logged in to the Vagrant box as the
ubuntu
user. cd /webapps/wevoteserver
. bin/activate
to activate thevirtualenv
cd WeVoteServer
Now you're the ubuntu
user, within virtualenv
, and in the root application directory. From here, you can run commands such as
./manage.py makemigrations
./manage.py migrate
And so on.