-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
63 lines (53 loc) · 1.59 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
# frozen_string_literal: true
require 'yaml'
def cpu_count
host = RbConfig::CONFIG['host_os']
# Give VM access to all cpu cores on the host
if host =~ /darwin/
`sysctl -n hw.ncpu`.to_i
elsif host =~ /linux/
`nproc`.to_i
else # sorry Windows folks, I can't help you
1
end
end
DEFAULTS = {
'box' => 'debian/contrib-stretch64',
'memory' => 1536,
'cpus' => cpu_count,
'ip' => nil
}
settings_file_path = File.dirname(__FILE__) + '/.vagrant.yml'
settings_file = if File.exist?(settings_file_path)
YAML.load(File.read(settings_file_path)) || {}
else
{}
end
SETTINGS = DEFAULTS.merge(settings_file).freeze
Vagrant.configure('2') do |config|
config.vm.box = SETTINGS['box']
if SETTINGS['ip']
config.vm.network :private_network, ip: SETTINGS['ip']
else
config.vm.network :forwarded_port, guest: 3000, host: 3000
end
config.vm.synced_folder '.', '/home/vagrant/app'
config.ssh.forward_agent = true
if Vagrant.has_plugin?("vagrant-vbguest")
config.vbguest.auto_update = false
end
config.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--memory', SETTINGS['memory']]
vb.customize ['modifyvm', :id, '--cpus', SETTINGS['cpus']]
end
config.vm.provision 'shell',
privileged: false,
path: 'script/provision-vagrant.sh'
config.vm.post_up_message = <<~EOT
Log into the Vagrant box with \`vagrant ssh\`
Run the test suite by \`./bin/rake\`
Start Rails server by \`./bin/rails server\`
Start all app processes with \`shoreman\`
Access the site at http://0.0.0.0:3000.
EOT
end