# ~/.vagrant.d/Vagrantfile # Local configuration to use across all Vagrant machines Vagrant.configure("2") do |config| config.vm.provider :virtualbox do |vb| host = RbConfig::CONFIG['host_os'] # Force settings for allowed resources if host =~ /darwin/ # Dynamically look up resources for Macs 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 elsif host =~ /linux/ # Improve linux performance by only counting physical cores and not hyperthreads cpus = `grep "cpu cores" /proc/cpuinfo |sort -u |cut -d":" -f2`.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 else # sorry Windows folks, I can't help you # Fall back to statically set values # **Note**: Update these for your system if using this cpus = "4" mem = "4096" end # Adjust values here if you don't want to allow access to all resources # Eg. mem = mem / 4 # This would limit access to only a quarter of total memory # Increase allowed memory usage and cpus vb.customize ["modifyvm", :id, "--cpuexecutioncap", "90", "--memory", mem, "--cpus", cpus] end # vagrant-cachier plugin configuration if Vagrant.has_plugin?("vagrant-cachier") # Cache downloaded packages per box config.cache.scope = :box end # vagrant-exec plugin configuration if Vagrant.has_plugin?("vagrant-exec") # By default run vagrant-exec commands within the /vagrant directory config.exec.commands '*', directory: '/vagrant' # Run all drush commands within the Drupal root config.exec.commands 'drush', directory: '/vagrant/docroot' end end