These files provision a VM for rails development with:
-
Ubuntu Trusty 64
-
rbenv
-
MySQL
-
nodejs for javascript
Assuming you have Vagrant and VirtualBox already installed you can use these files the following way.
-
Clone this repository to your computer
-
Install the Vagrant plugins
vagrant plugin install vagrant-vbguest vagrant plugin install vagrant-librarian-chef-nochef
-
Copy
Vagrantfile
andCheffile
to the root of our Rails project -
Update the database username and password in
Vagrantfile
to what's in yourdatabase.yml
-
Update the ruby version to match your
Gemfile
-
Add the following to your
.gitignore
to keep the files generated by Chef and Vagrant out of your repo./.vagrant /cookbooks
-
Run
vagrant up
and then go get a ☕. It takes a while for the VM to be created and provisioned. -
vagrant ssh
to access the VM -
cd /vagrant
-
bundle install
-
rails s
-
Access your app at
http:localhost:3000
Depending on what gems you include in your app, you might find it necessary to add additional software to you VM.
A number of file uploader gems require imagemagick to be on the server. You can easily add it to your VM by adding a couple lines to your vagrant config.
-
Add
cookbook 'imagemagick', '~> 0.2.3'
to yourCheffile
-
Add
chef.add_recipe "imagemagick"
to the block inVagrantfile
where you configure chef solo
-
If you're app is Rails 4.2, you'll need to run
rails s -b 0.0.0.0
. -
You might need to change the host port if you have multiple vagrant VMs running on your system.