Created
March 1, 2017 13:21
-
-
Save hungtrinh/247a49e1e9bb16124c3e02e44b40a880 to your computer and use it in GitHub Desktop.
Vagrant configuration file with OS detection
- on windows we mount shared folders without NFS
- on all other OS we use NFS for speeding up the project inside the virtual machine
This file contains hidden or 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
module OS | |
def OS.windows? | |
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil | |
end | |
def OS.mac? | |
(/darwin/ =~ RUBY_PLATFORM) != nil | |
end | |
def OS.unix? | |
!OS.windows? | |
end | |
def OS.linux? | |
OS.unix? and not OS.mac? | |
end | |
end | |
Vagrant.configure("2") do |config| | |
config.vm.box = "raring64" | |
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box" | |
config.vm.network :forwarded_port, guest: 80, host: 8080, auto_correct: true | |
config.vm.network :private_network, ip: "192.168.50.50" | |
if (defined?(OS.windows)).nil? | |
config.vm.synced_folder "../.", "/var/www/local.project.com", :mount_options => [ "dmode=775", "fmode=774" ] | |
else | |
config.vm.synced_folder "../.", "/var/www/local.project.com", :mount_options => [ "dmode=775", "fmode=774" ], :nfs => true | |
end | |
config.vm.provider :virtualbox do |vb| | |
# vb.gui = true | |
vb.customize ["modifyvm", :id, "--memory", "512", "--cpuexecutioncap", "90", "--name", "local.project.com"] | |
end | |
config.vm.provision :shell, :path => "bootstrap.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment