Vagrant is an easy way to create and distribute local self-contained development environments. When developing GeoKey, we used Vagrant together with VirtualBox to deploy a development environment in just under ten minutes. This guide walks you through the process of setting up a Vagrant environment for devolping GeoKey.
Install Vagrant and VirtualBox on your machine.
Fork the repository to your account.
Clone the repository:
git clone https://github.com/[YOUR_GITHUB_ACCOUNT_HANDLE]/geokey
Copy the directory local_settings.example
to local_settings
. In the directory local_settings
, open settings.py
in your text editor and update the database settings to:
DATABASES = {
'default': {
...
'USER': 'django',
'PASSWORD': 'django123',
'HOST': 'localhost',
...
}
}
Fire up the Vagrant VM:
vagrant up
Log into the VM via ssh:
vagrant ssh
Navigate to the shared directory and
cd /vagrant/
sudo pip install -e .
Run the tests, to see if things work out:
python manage.py test --nocapture --nologcapture
Migrate the database
python manage.py migrate
Create a superuser
python manage.py createsuperuser
If all went well, run the test server:
python manage.py runserver 0.0.0.0:8000
You now should be able to access the admin interface from your browser via http://localhost:4000.
You have now successfully set up a self contained development environment.
To shut down the VM and save its state use:
vagrant halt
And to restart it again use:
vagrant up
If, on your host machine, the port 4000 is already used for another application, you need to change the following line in the Vagrantfile
:
config.vm.network "forwarded_port", guest: 8000, host: 4000
Replace host: 4000
with whatever port you want to use in your host to access the Vagrant box.