Skip to content

Instantly share code, notes, and snippets.

@davidhooey
Last active November 12, 2020 16:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davidhooey/8013440 to your computer and use it in GitHub Desktop.
Save davidhooey/8013440 to your computer and use it in GitHub Desktop.
Vagrant Rails Development
# -*- mode: ruby -*-
# vi: set ft=ruby :
# -----------------------------------------------------------------------------
# Rails Development Vagrantfile
# -----------------------------------------------------------------------------
#
# Server Info:
#
# Ubuntu 12.04 32-bit
# PostgreSQL
# SQLite3
# Git
# RVM
# Ruby
# Rails
# VIM
#
# Setup
#
# 1. Install Vagrant and VirtualBox.
#
# 2. Create a directory to be the Rails home.
#
# 3. Save this Vagrantfile to the Rails home created in the previous step.
#
# 4. Edit the Vagrantfile to specify the Ruby and Rails versions.
#
# 5. Issue 'vagrant up' to start and provision the server.
#
# 6. SSH into the machine using 'vagrant ssh'.
#
# 7. Configure Postgres if required.
#
# 8. Create Rails application 'rails new /vagrant'
# -----------------------------------------------------------------------------
$as_root = <<AS_ROOT
echo Running root script...
sudo apt-get -y update
sudo apt-get -y install vim
sudo apt-get -y install curl
sudo apt-get -y install git
sudo apt-get -y install sqlite3
sudo apt-get -y install postgresql-client postgresql libpq-dev
echo Root script complete.
AS_ROOT
$as_vagrant = <<AS_VAGRANT
echo Running vagrant script...
curl -sSL https://get.rvm.io | bash -s stable --ruby=2.0.0
echo 'source /home/vagrant/.rvm/scripts/rvm' >> ~/.profile
source ~/.profile
rvm use ruby-2.0.0
rvm default ruby-2.0.0
gem update --system
gem install bundler --no-rdoc --no-ri
gem install rails -v=4.0.2 --no-rdoc --no-ri
gem install sqlite3 --no-rdoc --no-ri
gem install pg --no-rdoc --no-ri
echo Vagrant script complete.
AS_VAGRANT
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provision :shell, :inline => $as_root, :privileged => true
config.vm.provision :shell, :inline => $as_vagrant, :privileged => false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment