forked from rlerdorf/php7dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp7dev.rb
More file actions
79 lines (70 loc) · 2.89 KB
/
php7dev.rb
File metadata and controls
79 lines (70 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
class Php7dev
def Php7dev.configure(config, settings)
# Configure The Box
config.vm.box = "rasmus/php7dev"
config.vm.hostname = "php7dev"
# Configure A Private Network IP
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.7.7"
if settings['networking'][0]['public']
config.vm.network "public_network", type: "dhcp"
end
# Configure A Few VirtualBox Settings
config.vm.provider "virtualbox" do |vb|
vb.name = 'php7dev'
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"]
vb.customize ["modifyvm", :id, "--ostype", "Debian_64"]
vb.customize ["modifyvm", :id, "--audio", "none", "--usb", "off", "--usbehci", "off"]
end
# Configure Port Forwarding To The Box
config.vm.network "forwarded_port", guest: 80, host: 8000
config.vm.network "forwarded_port", guest: 443, host: 44300
config.vm.network "forwarded_port", guest: 3306, host: 33060
# Add Custom Ports From Configuration
if settings.has_key?("ports")
settings["ports"].each do |port|
config.vm.network "forwarded_port", guest: port["guest"], host: port["host"], protocol: port["protocol"] ||= "tcp"
end
end
if !Vagrant::Util::Platform.windows?
# Configure The Public Key For SSH Access
settings["authorize"].each do |key|
if File.exists? File.expand_path(key) then
config.vm.provision "shell" do |s|
s.inline = "echo $1 | grep -xq \"$1\" /home/vagrant/.ssh/authorized_keys || echo $1 | tee -a /home/vagrant/.ssh/authorized_keys"
s.args = [File.read(File.expand_path(key))]
end
end
end
# Copy The SSH Private Keys To The Box
settings["keys"].each do |key|
if File.exists? File.expand_path(key) then
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(File.expand_path(key)), key.split('/').last]
end
end
end
end
# Register All Of The Configured Shared Folders
if settings['folders'].kind_of?(Array)
settings["folders"].each do |folder|
config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil
end
end
# Configure All Of The Configured Databases
settings["databases"].each do |db|
config.vm.provision "shell" do |s|
s.path = "./scripts/create-mysql.sh"
s.args = [db]
end
end
# Update Composer On Every Provision
config.vm.provision "shell" do |s|
s.inline = "/usr/local/bin/composer self-update --no-progress"
end
end
end