Created
August 27, 2014 14:11
-
-
Save EranSch/775b0d4dafa34a428ad4 to your computer and use it in GitHub Desktop.
Heroku Vagrantfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant.configure("2") do |config| | |
config.vm.box = "heroku" | |
config.vm.box_url = "https://dl.dropboxusercontent.com/s/rnc0p8zl91borei/heroku.box" | |
config.vm.network "forwarded_port", guest: 8000, host: 8080 | |
config.vm.network "forwarded_port", guest: 1080, host: 9080 | |
config.vm.network :private_network, ip: '192.168.50.50' | |
config.vm.synced_folder '.', '/vagrant', nfs: true | |
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