Skip to content

Instantly share code, notes, and snippets.

@leobauza
Last active May 27, 2016 13:43
Show Gist options
  • Save leobauza/317a2f68f81c45fd56c9d3221429f282 to your computer and use it in GitHub Desktop.
Save leobauza/317a2f68f81c45fd56c9d3221429f282 to your computer and use it in GitHub Desktop.
Vagrantfile for scotchbox
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "192.168.33.10"
#config.vm.network "public_network", ip: "192.168.33.10"
config.vm.hostname = "scotchbox"
config.vm.synced_folder "../../Sites", "/var/www", type: "nfs"
#:mount_options => ["dmode=777", "fmode=666"]
config.vm.network :forwarded_port, host: 8080, guest: 80
# use all available memory
config.vm.provider "virtualbox" do |v|
host = RbConfig::CONFIG['host_os']
# Give VM 1/4 system memory & access to all cpu cores on the host
if host =~ /darwin/
cpus = `sysctl -n hw.ncpu`.to_i
# sysctl returns Bytes and we need to convert to MB
mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
elsif host =~ /linux/
cpus = `nproc`.to_i
# meminfo shows KB and we need to convert to MB
mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4
else # sorry Windows folks, I can't help you
cpus = 2
mem = 1024
end
v.customize ["modifyvm", :id, "--memory", mem]
v.customize ["modifyvm", :id, "--cpus", cpus]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment