Permalink
Browse files

Vagrant: Vagrantfile and README improvements.

* Vagrantfile:
Use `:privilege => false` to bypass npm issues.
Use `:run => always` to always run on `vagrant up`

* README:
Update Vagrant section.
  • Loading branch information...
littlebtc committed May 13, 2014
1 parent 81491a8 commit 8bba15c31d80e45d02bc1d73520614e51c3a211d
Showing with 37 additions and 16 deletions.
  1. +10 −7 README.md
  2. +27 −9 Vagrantfile
View
@@ -39,21 +39,24 @@ Check it with the following commands:
Then after the building message completes, connect to http://localhost:3333/.
# Using vagrant to develop
# Using Vagrant to develop
[Vagrant](http://docs.vagrantup.com/v2/why-vagrant/index.html) provides easy to configure, reproducible, and portable work environments.
[Vagrant](http://docs.vagrantup.com/v2/why-vagrant/index.html) provides easy-to-configure, reproducible, and portable work environments. It will create a headless VirtualBox VM, then prepare the development environment and launch the server for you. You can then develop and test the code anywhere :).
To use vagrant, you need to install:
To use Vagrant, you need to install:
- vagrant (> 1.1.x)
- virtualbox
- Vagrant (>= 1.6.x)
- VirtualBox
To setup up work environment:
% vagrant box add g0v https://dl.dropboxusercontent.com/u/4339854/g0v/g0v-ubuntu-precise64.box
% vagrant up
After `vagrant up`, browse http://localhost:6987/ in your favorite browser. You are all set!
It will several minutes for the first time, since it will have to configure its Ubuntu VM image. After the operation is finished, browse to `http://localhost:6987/` in your favorite browser. You are all set!
`vagrant halt` if you need to shut down the Vagrant VM. For more information about Vagrant, see the [documentation of Vagrant](http://docs.vagrantup.com).
Note: Have to use older Vagrant (1.3.0+)? Change the `Vagrantfile`.
# Google API key
View
@@ -1,29 +1,47 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# a known issue that symbolic link can not be created in virtualbox shared fold
# Install the Git and node.js from PPA
$setup_script = <<RUNONCE
sudo apt-get update
sudo apt-get install -y python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install -y nodejs git-core
RUNONCE
# a known issue that symbolic link cannot be created in VirtualBox shared folder.
# we have to workround npm modules installaltion.
$script = <<SCRIPT
mkdir -p /tmp/node_modules /vagrant/node_modules
sudo mount --bind /tmp/node_modules /vagrant/node_modules
$up_script = <<ALWAYSRUN
mkdir -p /home/vagrant/tmp_node_modules /vagrant/node_modules
sudo mount --bind /home/vagrant/tmp_node_modules /vagrant/node_modules
cd /vagrant
npm i
npm install
npm run start
SCRIPT
ALWAYSRUN
# Vagrant dependencies:
# * 1.6.0 -> Allow shell provision always run with :run => 'always'
# * 1.3.0 -> Run shell provision with SSH user by :privileged => false
# Delete this line for Vagrant 1.3 ~ 1.5
Vagrant.require_version ">= 1.6.0"
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "g0v"
config.vm.provision :shell, :inline => $script
config.vm.box = "hashicorp/precise64"
config.vm.provision :shell, :inline => $setup_script, :privileged => false
# Remove the `, :run => 'always'` for Vagrant 1.3 ~ 1.5
config.vm.provision :shell, :inline => $up_script, :privileged => false, :run => 'always'
config.vm.network :forwarded_port, host: 6987, guest: 3333
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "https://dl.dropboxusercontent.com/u/4339854/g0v/g0v-ubuntu-precise64.box"
# config.vm.box_url = "https://dl.dropboxusercontent.com/u/4339854/g0v/g0v-ubuntu-precise64.box"
# 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,

0 comments on commit 8bba15c

Please sign in to comment.