|
| 1 | +## Run DevTracker Locally Using Vagrant |
| 2 | + |
| 3 | +[Back to README.md](../README.md) |
| 4 | + |
| 5 | +If you do not want to setup the whole environment using the manual process and would rather prefer a quick vagrant setup, please follow the below steps. |
| 6 | + |
| 7 | +``` |
| 8 | +vagrant up |
| 9 | +vagrant ssh |
| 10 | +
|
| 11 | +# Give execute permission to the following scripts |
| 12 | +chmod +x /vagrant/vagrant-requirements/post-setup-phase-1.sh |
| 13 | +chmod +x /vagrant/vagrant-requirements/post-setup-phase-2.sh |
| 14 | +
|
| 15 | +# Run the first script |
| 16 | +/vagrant/vagrant-requirements/post-setup-phase-1.sh |
| 17 | +
|
| 18 | +# Exit from the console as the running scripts need a reloaded login of the current user |
| 19 | +exit |
| 20 | +
|
| 21 | +# Login again using vagrant ssh |
| 22 | +vagrant ssh |
| 23 | +
|
| 24 | +# Run the following script |
| 25 | +/vagrant/vagrant-requirements/post-setup-phase-2.sh |
| 26 | +
|
| 27 | +# Once everything's complete, edit devtracker.rb to a publicly accessible OIPA endpoint. Just follow [this link](https://github.com/DFID/devtracker-from-api/wiki#do-this-first-on-a-dev-machine) to make the change. |
| 28 | +
|
| 29 | +# Run the following command |
| 30 | +cd /vagrant |
| 31 | +ruby devtracker.rb -o 0.0.0.0 -p 4567 |
| 32 | +
|
| 33 | +# Now from the host machine web browser, go to http://localhost:8080 and you will have a running devtracker |
| 34 | +``` |
| 35 | + |
| 36 | +### Debugging in VS Code |
| 37 | + |
| 38 | +After successfully setting up Vagrant, run `vagrant ssh-config` in the main working directory. This will return something like this: |
| 39 | + |
| 40 | +``` |
| 41 | +Host default |
| 42 | + HostName 127.0.0.1 |
| 43 | + User vagrant |
| 44 | + Port 2222 |
| 45 | + UserKnownHostsFile /dev/null |
| 46 | + StrictHostKeyChecking no |
| 47 | + PasswordAuthentication no |
| 48 | + IdentityFile /Users/roryscott/Code/DFID/devtracker-from-api/.vagrant/machines/default/virtualbox/private_key |
| 49 | + IdentitiesOnly yes |
| 50 | + LogLevel FATAL |
| 51 | +``` |
| 52 | + |
| 53 | +Change the `Host` variable to `devtracker_vagrant` and adding the following entry in the `.ssh/config` file (shown when you set up a new remote connection using VS Codes 'Remote Explorer' plugin). This will allow you to run a client of VS Code from within the vagrant box. |
| 54 | + |
| 55 | +In turn, you can install the "Ruby" extension for VS Code which allow for linting and de-bugging. |
| 56 | + |
| 57 | +To do this, the following steps are required: |
| 58 | + |
| 59 | +1. vagrant up within the home directory |
| 60 | +2. connect to remote instance by going to remote explorer > ssh targets, and connecting to `devtracker_vagrant` |
| 61 | +3. within devtracker vagrant open the `/vagrant/` folder in VS Code Explorer |
| 62 | +4. within devtracker vagrant open a terminal and run `sudo gem install ruby-debug-ide; sudo gem install debase` |
| 63 | +5. go to the 'Run' window and run 'Debug DevTracker` |
| 64 | + |
| 65 | +You can now visit the dev instance by going to `localhost:8080` on your host machine, and you can enter breakpoints in the ruby code within the remote VS Code session and interactively debug. |
0 commit comments