Skip to content

Commit 74e56d9

Browse files
committed
changes to allow for VS Code vagrant development
1 parent aa11d9f commit 74e56d9

File tree

4 files changed

+84
-25
lines changed

4 files changed

+84
-25
lines changed

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Debug DevTracker",
9+
"type": "Ruby",
10+
"request": "launch",
11+
"program": "${workspaceRoot}/devtracker.rb"
12+
}
13+
]
14+
}

README.md

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,6 @@ The open public API being used in the [OIPA API](https://www.oipa.nl/home) built
1717
## Get started
1818
The site is being developed using a Sinatra web framework and Ruby. To get started, go to the [Wiki](https://github.com/DFID/devtracker-from-api/wiki). We will be adding new guidance and features to the wiki as we go along.
1919

20-
## Load DevTracker Using Vagrant
21-
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
22-
23-
```
24-
vagrant up
25-
vagrant ssh
26-
# Give execute permission to the following scripts
27-
chmod +x /vagrant/vagrant-requirements/post-setup-phase-1.sh
28-
chmod +x /vagrant/vagrant-requirements/post-setup-phase-2.sh
29-
# Run the first script
30-
/vagrant/vagrant-requirements/post-setup-phase-1.sh
31-
# Exit from the console as the running scripts need a reloaded login of the current user
32-
exit
33-
# Login again using vagrant ssh
34-
vagrant ssh
35-
# Run the following script
36-
/vagrant/vagrant-requirements/post-setup-phase-2.sh
37-
# 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.
38-
# Run the following command
39-
cd /vagrant
40-
ruby devtracker.rb -o 0.0.0.0 -p 4567
41-
42-
# Now from the host machine web browser, go to http://localhost:8080 and you will have a running devtracker
43-
```
20+
## Local Development
21+
22+
See [this page](docs/local_development.md) for details of running with vagrant and interactively debugging using VS Code.

devtracker.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
include RecaptchaHelper
5454

5555
# Developer Machine: set global settings
56-
#set :oipa_api_url, 'https://devtracker-staging.oipa.nl/api/'
56+
# set :oipa_api_url, 'https://devtracker-staging.oipa.nl/api/'
57+
# set :bind, '0.0.0.0' # Allows for vagrant pass-through whilst debugging
5758

5859
# Server Machine: set global settings to use varnish cache
5960
set :oipa_api_url, 'http://127.0.0.1:6081/api/'

docs/local_development.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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

Comments
 (0)