A Vagrant VM for GRUG Projects
This project automates the setup of a development environment for general Ruby on Rails application development. It is particularly bootstrapped to support projects for the Golden Ruby User Group (GRUG).
Download and install both of these.
How To Build The Virtual Machine
Building the virtual machine is this easy:
host $ git clone https://github.com/grug/grug-starter-box.git host $ cd grug-starter-box host $ git submodule update --init host $ vagrant up
If the base box is not present that command fetches it first.
NOTE: This will take a while the first time!
How To Access The Virtual Machine
host $ vagrant ssh Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686) ... vagrant@grug-starter-box:~$
Port 3000 in the host computer is forwarded to port 3000 in the virtual machine. Thus, applications running in the virtual machine can be accessed via localhost:3000 in the host computer.
What's In The Box
SQLite3, MySQL, Postgres and MongoDB
RVM (with ruby 1.9.3 and 2.0.0 installed)
Bundler, Rails and Rake gems for both rubies
Projects folder that includes these GRUG projects:
Setting up a Project
To start using one of the projects, you'll need to:
- (optionally) fork the repo from Github
- visit the project (URL above) and fork it to your own Github account
- reset the remote on the project to your forked repo
- use one of the rvm gemsets
- run Bundler
- optionally start up Rails
I.E. to start coding on the DDD Sample App using your own fork:
Let's assume your fork is at: https://github.com/bestgrugmember/ddd_sample_app_ruby
host $ cd projects/ddd_sample_app_ruby host $ git remote set-url origin git://github.com/bestgrugmember/ddd_sample_app_ruby.git host $ git pull host $ vagrant ssh vagrant@grug-starter-box:~$ cd /vagrant/projects/ddd_sample_app_ruby vagrant@grug-starter-box:/vagrant/projects/ddd_sample_app_ruby$ rvm use 2.0.0@grug vagrant@grug-starter-box:/vagrant/projects/ddd_sample_app_ruby$ bundle vagrant@grug-starter-box:/vagrant/projects/ddd_sample_app_ruby$ rails server
You can then access the Rails server via localhost:3000 from your host machine.
I.E. to start coding on the Camping app without a fork:
host $ cd projects/camping host $ git pull host $ vagrant ssh vagrant@grug-starter-box:~$ cd /vagrant/projects/camping vagrant@grug-starter-box:/vagrant/projects/camping$ rvm use 2.0.0@grug vagrant@grug-starter-box:/vagrant/projects/camping$ bundle vagrant@grug-starter-box:/vagrant/projects/camping$ rspec vagrant@grug-starter-box:/vagrant/projects/camping$ cucumber
The recommended workflow is
edit files in the host computer (wherever you did the git clone)
run within the virtual machine (mounted files are in /vagrant)
You can keep one terminal open that is SSH'd into your vagrant VM and one terminal open that has your code changes for git management.
Virtual Machine Management
When done just log out with and suspend the virtual machine
host $ vagrant suspend
then, resume to hack again
host $ vagrant resume
host $ vagrant halt
to shutdown the virtual machine, and
host $ vagrant up
to boot it again.
You can find out the state of a virtual machine anytime by invoking
host $ vagrant status
Finally, to completely wipe the virtual machine from the disk destroying all its contents:
host $ vagrant destroy # DANGER: all is gone
Please check the Vagrant documentation for more information on Vagrant.