This repository was archived by the owner on Aug 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
55 lines (43 loc) · 1.67 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "debian/contrib-buster64"
## Forward ssh config
config.ssh.forward_agent = true
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y git
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
SHELL
## Provision
config.vm.provision :shell, path: "server/provision.sh", args: "badgerherald.test", privileged: false
# Hostname
config.vm.network :private_network, :ip => "192.168.19.69"
config.vm.network "private_network", type: "dhcp"
# Mount vagrant
config.vm.synced_folder ".", "/home/vagrant/badgerherald.com", :group => "www-data", :mount_options => ['dmode=775','fmode=664']
# Performance improvements
# 1. Assign a quarter of host memory and all available CPU's to VM
# Depending on host OS this has to be done differently.
# 2. set --natdnshostresolver1 & --natdnsproxy1 to speed up external connections
config.vm.provider :virtualbox do |vb|
host = RbConfig::CONFIG['host_os']
if host =~ /darwin/
cpus = `sysctl -n hw.ncpu`.to_i
mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
elsif host =~ /linux/
cpus = `nproc`.to_i
mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4
# Windows...
else
cpus = 4
mem = 2048
end
vb.customize ["modifyvm", :id, "--memory", mem]
vb.customize ["modifyvm", :id, "--cpus", cpus]
vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']
end
end