mlouie/dchousing-apps — pull request #126 by MikeyBurkman (2014-08-17 20:00:01+00:00)
Title: Added Vagrant File for Easier Onboarding

Adds a VagrantFile and Puppet config for easy and consistent onboarding, no matter what OS the dev is using. Also creates a nice sandbox environment, which makes it easier to upgrade dependency versions. (As well as making it much easier to develop other Rails apps alongside this one.)

First you'll need to download Vagrant and Oracle VirtualBox (it works with some other VMs supposedly but I've only tested on VB). Both are free.

From the command line, navigate to the dchousing-apps root folder, and enter `vagrant up`
This will create the VM, install ruby, pdftk, rails, sqlite, memcache, and all the gems on the VM. It takes a few minutes. Go get some coffee.

Once the VM is up, call `vagrant ssh` to connect to the new VM, which will act as your Rails server.
In the VM, navigate to /vagrant (`cd /vagrant`), which is where the dchousing-apps files will be. This directory is shared between the VM and your host machine. It syncs in both directions!
From here, set up the DB like you normally would: `rake db:setup`. (I'd like to automate this step as well in the Puppet config, but it's getting test errors when I do.) You'll of course only need to do this the first time you create the VM.
Now the server is ready to go! Enter `rails server` and it should start.
Open up a browser on your host machine (not the VM), and go to `http://localhost:3000` to access the app.
Edit files on your host machine the same way you normally would. The VM is just for running Rails and the DB. Because your host machine the VM sync automatically, you should never need to manually copy any files between the two.

To exit out of the VM, press Ctrl+C to stop the server if it's running, and enter `exit` to end the SSH session and return back to your host machine.
Enter `vagrant halt` to stop your VM. Entering `vagrant up` again should restart the VM.

You can also destroy the VM, along with all the Ruby and DB stuff, by entering `vagrant destroy`. You can destroy and rebuild the VM without messing up any of your files you've checked out. So no worries about messing up your environment!