forked from coderwall/coderwall-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
80 lines (65 loc) · 3.01 KB
/
Vagrantfile
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
80
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Load in custom vagrant settings
require 'yaml'
custom_settings = File.file?('vagrant.yml') ? YAML.load_file('vagrant.yml') : {}
puts '== Using Custom Vagrant Settings =='
puts custom_settings.inspect
VAGRANTFILE_API_VERSION = "2"
$box = 'coderwall'
$box_url = 'https://s3.amazonaws.com/coderwall-assets-0/vagrant/coderwall.box' # The box is 1GB. Prepare your
$provision = 'vagrant/bootstrap.sh'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = $box
config.vm.box_url = $box_url
config.vm.provision :shell do |s|
s.path = $provision
end
config.ssh.keep_alive = true
config.ssh.forward_agent = true
config.vm.network :private_network, ip: '192.168.237.95' # 192.168.cdr.wl
set_port_mapping_for(config, 'elasticsearch', 9200, custom_settings)
set_port_mapping_for(config, 'mongodb', 27017, custom_settings)
set_port_mapping_for(config, 'postgres', 5432, custom_settings)
set_port_mapping_for(config, 'redis', 6379, custom_settings)
set_port_mapping_for(config, 'rails', 3000, custom_settings, true)
if sync_settings = custom_settings['sync']
config.vm.synced_folder '.', '/home/vagrant/web', nfs: sync_settings['use_nfs']
end
config.vm.provider :virtualbox do |vb|
# Use custom settings unless they don't exist
if virtualbox_settings = custom_settings['virtualbox']
vb.customize ['modifyvm', :id, '--cpus', "#{virtualbox_settings['cpus'] || 2}"]
vb.customize ['modifyvm', :id, '--memory', "#{virtualbox_settings['memory'] || 2048}"]
else
vb.customize ['modifyvm', :id, '--cpus', '2']
vb.customize ['modifyvm', :id, '--memory', '2048']
end
vb.customize ['modifyvm', :id, '--ioapic', 'on']
# https://github.com/mitchellh/vagrant/issues/1807
# whatupdave: my VM was super slow until I added these:
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
# seems to be safe to run: https://github.com/griff/docker/commit/e5239b98598ece4287c1088e95a2eaed585d2da4
end
if Vagrant.has_plugin?('vagrant-vbguest')
config.vbguest.auto_update = true
config.vbguest.no_remote = false
else
puts "Please install the 'vagrant-vbguest' plugin"
end
end
def set_port_mapping_for(config, service, guest_port, settings, force = false)
if settings['network'] && settings['network']['port_mappings'] && settings['network']['port_mappings'][service]
host_port = settings['network']['port_mappings'][service]
puts " !! Setting up port mapping rule for #{service} host:#{host_port} => guest:#{guest_port}"
config.vm.network(:forwarded_port, guest: guest_port, host: host_port)
else
# no host port mapping was defined
if force
# but we want to force a mapping for the default ports
puts " !! Setting up port mapping rule for #{service} host:#{guest_port} => guest:#{guest_port}"
config.vm.network(:forwarded_port, guest: guest_port, host: guest_port)
end
end
end