Using Vagrant to set up a Development Environment

From GCD
Jump to: navigation, search

Setting up a development environment for the GCD is quite easy using Vagrant.

Setting up the environment

  1. Download Vagrant
  2. Download VirtualBox (does it automatically install with Vagrant?)
  3. Visit this page and download the zip file
  4. Unzip the file into an easily accessible directory. This guide assumes a Windows environment and putting the file in C:\gcd
  5. Open a command prompt and go to the directory C:\gcd
  6. Enter "vagrant up" and wait... it may take a while
  7. Enter "vagrant provision" (this step may or may not be necessary, depending on how well the scripts ran during "vagrant up")
  8. Download git from (this isn't necessary for having the webpage work, but for many of the subsequent directions it will be necessary)

At this point you should be able to visit the webpage http://localhost:8000 and see a version of the front page of the GCD. Searching for anything using the "advanced search" will bring you no results (because you just have a blank database) and searching for anything with the "new search" will get you an error (because the elastisearch has not been indexed).

If you shut down your computer, the virtual server will also be shut down. In order to start it the next time simply open the command prompt, go to the directory and enter "vagrant up". It will boot up the virtual server, probably taking less than 5 minutes.

To install a dump of the database

  1. Download the newest version of the dump from (you will need a free GCD account in order to access the data... please read our terms and conditions).
  2. Place the zip file (probably called in the base folder C:\gcd
  3. Open the Git Shell (downloaded as part of git above)
  4. Type "vagrant ssh"
  5. Type "sudo apt-get install unzip" (this will download the unzip program)
  6. Type "unzip -dc /vagrant/" (this will unzip the sql file)
  7. Type "mysql -u root -pgcd gcd < c/2015-04-01.sql" (replacing the file name with whatever the previous unzip command tells you the file name is)
  8. Wait... probably at least 1/2 an hour. When it is done, the prompt will return and you will have data in your database.

To index the New Search

  1. Warning... this will take a long time on the full database, probably at least a day. Unless you are specifically going to work on the new search it is probably not necessary to do this.
  2. Open the Git Shell (downloaded as part of git above)
  3. Type "vagrant ssh"
  4. Type "source /home/vagrant/virtualenv/bin/activate"
  5. Type "cd /vagrant/gcd-django"
  6. Type "./ rebuild_index"

To make changes to your local version of the webpages

  1. Go to the directory c:\gcd\apps
  2. Any changes made will be visible immediately locally