Skip to content

A Vagrant Box with Ruby 2, Rails 4, Middleman 3, and Foreman Baked In. PostGres is pre-built for rails development as well. Full Installation instructions for OSX and Windows XP/7/8

License

Notifications You must be signed in to change notification settings

dannyvassallo/rails-middleman-vagrant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Vagrant Box For Rails and Middleman Development

Based On Rails-Dev-Box


What's in it?

  • Development tools
  • Git
  • Ruby 2.2
  • Bundler
  • SQLite3, MySQL, and Postgres
  • Databases and users needed to run the Active Record test suite
  • System dependencies for nokogiri, sqlite3, mysql, mysql2, and pg
  • Memcached
  • Redis
  • RabbitMQ
  • An ExecJS runtime
  • Foreman
  • Middleman

Getting Started

For OSX/Linux/Windows

  1. Download and Install Vagrant

  2. Download and Install Virtualbox

  3. Download and open/install the appropriate VM Virtualbox Extension Pack

  4. Ensure git CLI on host machine

/// FOR WINDOWS ONLY SKIP AHEAD TO VAGRANT BOX SECTION IF USING OSX ///

  1. Download and Install PuTTy putty.exe

  2. Download and Install PuTTYgen puttygen.exe


Git Clone the repo where ever you'd like the machine

$ git clone https://github.com/dannyvassallo/rails-middleman-vagrant.git
$ cd rails-middleman-vagrant

Vagrant Box

###Macintosh OS X

####Setting Memory and Processor Power in Vagrant

navigate to the cloned repo

cd rails-middleman-vagrant

Open 'Vagrantfile' with sublime text

Replace it's contents with these changing the number following v.cpus to update the number of processor cores and changing the number following v.memory to your desired RAM specs.

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
  config.vm.box      = 'ubuntu/trusty64'
  config.vm.hostname = 'danny-rails-middleman'

  config.vm.network :forwarded_port, guest: 3000, host: 3000

  config.vm.provision :shell, path: 'bootstrap.sh', keep_color: true

  config.vm.provider 'virtualbox' do |v|
    v.cpus = 2
    v.memory = 2048
  end

end

If you've run vagrant up before setting up your memory run:

$ vagrant destroy
$ vagrant up && vagrant provision

######Check Your Memory has been successfully changed

$ cd rails-middleman-vagrant
$ vagrant up
$ vagrant ssh
$ free -m

The total memory reported should match closely to the v.memory inputted.

Start Vagrant

To Start up your VM

$ vagrant up

To SSH in to the VM:

$ vagrant ssh

Navigate to synced folders directory:

$ cd /vagrant

Stop Vagrant

To suspend:

vagrant suspend

To halt:

vagrant halt

###Windows XP/7/8

####Setting Memory and Processor Power in Vagrant

navigate to the cloned repo

cd rails-middleman-vagrant

Open 'Vagrantfile' with sublime text

Replace it's contents with these changing the number following v.cpus to update the number of processor cores and changing the number following v.memory to your desired RAM specs.

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
  config.vm.box      = 'ubuntu/trusty64'
  config.vm.hostname = 'danny-rails-middleman'

  config.vm.network :forwarded_port, guest: 3000, host: 3000

  config.vm.provision :shell, path: 'bootstrap.sh', keep_color: true

  config.vm.provider 'virtualbox' do |v|
    v.cpus = 2
    v.memory = 2048
  end

end

If you've run vagrant up before setting up your memory run:

$ vagrant destroy
$ vagrant up && vagrant provision

######Check Your Memory has been successfully changed

$ cd rails-middleman-vagrant
$ vagrant up

FOLLOW PUTTY INSTRUCTIONS BELOW

$ free -m

The total memory reported should match closely to the v.memory inputted.

Start Vagrant

To Start up your VM in cmd or powershell

$ vagrant up

1) Generate SSH Keys With PuTTyGen (You only do this once)

  • Open puttygen.exe

  • Click the "Load" button

  • To the right of Filename at the bottom change the drop down from "PuTTy Private Key Files (.ppk)" to "All Files ()"

  • Navigate to the cloned repo folder (example 'Desktop/Websites/rails-middleman-vagrant')

  • Navigate to the "private_key" file in ".vagrant/machines/default/virtualbox/private_key" and click open on this file.

  • Click 'Ok' to the PuTTyGen alert window

  • Click "Save Private Key"

  • Click 'Yes' to the PuTTyGen alert window

  • Name the .ppk file "private_key" without quotes

  • Save it in the same directory as putty for organization

  • Close PuTTyGen

To SSH in to the VM:

2) SSH into Vagrant with PuTTy (This is how you will vagrant-ssh)

  • Open putty.exe
IN SESSION:
  • Set "Host Name (or IP address)" to "127.0.0.1"
  • Set "Port" to "2222"
  • Set "Connection Type" to "SSH"
IN CONNECTION/SSH/AUTH:
  • Check "Display pre-authentication banner (SSH-2 only)"
  • Check "Attempt authenticating using Pageant"
  • Check "Attempt "keyboard-interactive" auth (SSH-2)"
  • Check "Allow agent forwarding"
  • Check "Allow attempted changes of username in SSH-2"
  • Click Browse and navigate to the "private_key.ppk" file you generated in the putty directory
IN SESSION:
  • Type "vagrant" (no quotes) in the Saved Sessions input
  • Click Save

To open the vagrant box from this point on you may skip the putty setup. You will only need to open the putty.exe file and double click "vagrant" in the saved sessions list after running "vagrant up" in cmd or powershell.

Navigate to synced folders directory:

$ cd /vagrant

Stop Vagrant

To suspend:

vagrant suspend

To halt:

vagrant halt

-- IN CASE OF ERROR ON VAGRANT UP --

Run:

$ lsof -i | grep LISTEN

If you see something listed like this:

VBoxHeadl 4405 my_name   18u  IPv4 0xffffff802a933320      0t0  TCP *:hbci (LISTEN)
VBoxHeadl 4405 my_name   19u  IPv4 0xffffff802bcf04e0      0t0  TCP localhost:rockwell-csp2 (LISTEN)

Run (replace 4405 with the number in your print out):

$ kill -9 4405

To check the process has been killed run:

$ lsof -i | grep LISTEN

The VBoxHeadl should be missing. You are good to now run:

$ vagrant up

PostGres Credentials

Taken from here

update your config/database.yml with these DB credentials:

development:
  
  username: coderelf
  password: password


test:
  
  username: coderelf
  password: password

To enable Hstore:

change 'MY_DATABASE' to your database name.

$ sudo su postgres -c "psql MY_DATABASE -c 'CREATE EXTENSION hstore;'"

Start Rails Server

don't use rails s. use this instead:

$ bin/rails s -b 0.0.0.0

Start A Middleman Server

don't use middleman s. use this instead:

$ bundle exec middleman s --port=3000

About

A Vagrant Box with Ruby 2, Rails 4, Middleman 3, and Foreman Baked In. PostGres is pre-built for rails development as well. Full Installation instructions for OSX and Windows XP/7/8

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages