Created
May 15, 2015 20:20
-
-
Save jameskraai/dddcbf28d8db9f1d8aab to your computer and use it in GitHub Desktop.
Modified to support nfs for better performance
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
class Homestead | |
def Homestead.configure(config, settings) | |
# Configure The Box | |
config.vm.box = "laravel/homestead" | |
config.vm.hostname = "homestead" | |
# Configure A Private Network IP | |
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10" | |
# Configure A Few VirtualBox Settings | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--memory", settings["memory"] ||= "2048"] | |
vb.customize ["modifyvm", :id, "--cpus", settings["cpus"] ||= "1"] | |
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] | |
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | |
end | |
# Configure Port Forwarding To The Box | |
config.vm.network "forwarded_port", guest: 80, host: 8000 | |
config.vm.network "forwarded_port", guest: 5000, host: 5000 | |
config.vm.network "forwarded_port", guest: 3306, host: 33060 | |
config.vm.network "forwarded_port", guest: 5432, host: 54320 | |
# Copy The Bash Aliases | |
config.vm.provision "shell" do |s| | |
s.inline = "cp /vagrant/aliases /home/vagrant/.bash_aliases" | |
s.inline = "sudo apt-get update" | |
s.inline = "sudo composer self-update" | |
end | |
# Register All Of The Configured Shared Folders | |
settings["folders"].each do |folder| | |
config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil, type: "nfs" | |
end | |
# Install All The Configured Nginx Sites | |
settings["sites"].each do |site| | |
config.vm.provision "shell" do |s| | |
if (site.has_key?("hhvm") && site["hhvm"]) | |
s.inline = "bash /vagrant/scripts/serve-hhvm.sh $1 $2" | |
s.args = [site["map"], site["to"]] | |
else | |
s.inline = "bash /vagrant/scripts/serve.sh $1 $2" | |
s.args = [site["map"], site["to"]] | |
end | |
end | |
end | |
# Configure All Of The Server Environment Variables | |
if settings.has_key?("variables") | |
settings["variables"].each do |var| | |
config.vm.provision "shell" do |s| | |
s.inline = "echo \"\nenv[$1] = '$2'\" >> /etc/php5/fpm/php-fpm.conf && service php5-fpm restart" | |
s.args = [var["key"], var["value"]] | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment