Skip to content

Commit

Permalink
Added a vagrant setup with the repository so that anyone can have a q…
Browse files Browse the repository at this point in the history
…uick setup of DevTracker in their machine.
  • Loading branch information
aunindadf committed Jun 25, 2020
1 parent 1d3fea9 commit 0803f3f
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,27 @@ The open public API being used in the [OIPA API](https://www.oipa.nl/home) built

## Get started
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.

## Load DevTracker Using Vagrant
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

```
vagrant up
vagrant ssh
# Give execute permission to the following scripts
chmod +x /vagrant/vagrant-requirements/post-setup-phase-1.sh
chmod +x /vagrant/vagrant-requirements/post-setup-phase-2.sh
# Run the first script
/vagrant/vagrant-requirements/post-setup-phase-1.sh
# Exit from the console as the running scripts need a reloaded login of the current user
exit
# Login again using vagrant ssh
vagrant ssh
# Run the following script
/vagrant/vagrant-requirements/post-setup-phase-2.sh
# 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.
# Run the following command
ruby devtracker.rb -o 0.0.0.0 -p 4567
# Now from the host machine web browser, go to http://localhost:8080 and you will have a running devtracker
```
71 changes: 71 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "hashicorp/bionic64"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

# Create a private network, which allows host-only access to the machine
# using a specific IP.
#config.vm.network "private_network", ip: "192.168.33.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
config.vm.network "forwarded_port", guest: 4567, host: 8080, auto_correct: true
#config.vm.network "public_network"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
config.vm.provision :shell, path: "vagrant-requirements/pre-setup.sh", privileged: false
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
end
7 changes: 7 additions & 0 deletions vagrant-requirements/post-setup-phase-1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
6 changes: 6 additions & 0 deletions vagrant-requirements/post-setup-phase-2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
cd /vagrant/
sudo rbenv install 2.5.2
sudo rbenv local 2.5.2
sudo gem install bundler -v '2.0.2'
bundle i
7 changes: 7 additions & 0 deletions vagrant-requirements/pre-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e

sudo apt-get update
sudo apt-get install -y build-essential git libssl1.0-dev libreadline-dev zlib1g-dev ruby-dev
exit
2 changes: 2 additions & 0 deletions vagrant-requirements/start-devtracker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
ruby devtracker.rb -o 0.0.0.0 -p 4567

0 comments on commit 0803f3f

Please sign in to comment.