Skip to content

Instantly share code, notes, and snippets.

@JPBetley
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JPBetley/37c9d0f6582a76f57192 to your computer and use it in GitHub Desktop.
Save JPBetley/37c9d0f6582a76f57192 to your computer and use it in GitHub Desktop.
Homestead changes
curl -L https://gist.githubusercontent.com/JPBetley/37c9d0f6582a76f57192/raw/Vagrantfile > Vagrantfile
curl -L https://gist.githubusercontent.com/JPBetley/37c9d0f6582a76f57192/raw/Homestead.yaml > Homestead.yaml
---
authorize: /Users/tatsumori/.ssh/id_rsa.pub
keys:
- /Users/tatsumori/.ssh/id_rsa
folders:
- map: /Users/tatsumori/Code
to: /home/vagrant/Code
sites:
- map: APP.dev
to: /home/vagrant/Code/APP/public
VAGRANTFILE_API_VERSION = "2"
path = "#{File.dirname(__FILE__)}"
require 'yaml'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
Homestead.configure(config, YAML::load(File.read(path + '/Homestead.yaml')))
end
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: "192.168.33.10"
# Configure A Few VirtualBox Settings
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
# Configure The Public Key For SSH Access
config.vm.provision "shell" do |s|
s.inline = "echo $1 | tee -a /home/vagrant/.ssh/authorized_keys"
s.args = [File.read(settings["authorize"])]
end
# Copy The SSH Private Keys To The Box
settings["keys"].each do |key|
config.vm.provision "shell" do |s|
s.privileged = false
s.inline = "echo \"$1\" > /home/vagrant/.ssh/$2 && chmod 600 /home/vagrant/.ssh/$2"
s.args = [File.read(key), key.split('/').last]
end
end
# Register All Of The Configured Shared Folders
settings["folders"].each do |folder|
config.vm.synced_folder folder["map"], folder["to"],
id: "core",
:nfs => true,
:mount_options => ['nolock,vers=3,udp,noatime']
end
# Install All The Configured Nginx Sites
settings["sites"].each do |site|
config.vm.provision "shell" do |s|
s.path = "https://raw.githubusercontent.com/laravel/homestead/master/scripts/serve.sh"
s.args = [site["map"], site["to"]]
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment