-
Notifications
You must be signed in to change notification settings - Fork 6
/
Vagrantfile
65 lines (45 loc) · 1.47 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
$script = <<SCRIPT
set -e
# set environment variables
cat >> ~/.profile << EOF
export LANG=C
export LC_CTYPE=C
export USE_CCACHE=y
EOF
# update apt-get repository
sudo apt-get update
# install base dependencies
sudo apt-get install -y --no-install-recommends \
g++ pkg-config libcurl4-openssl-dev python-dev ccache git
# install pip
wget -N -nv https://bootstrap.pypa.io/get-pip.py
sudo -H python get-pip.py
# install dev dependencies
cd /vagrant
sudo -H pip install -r requirements.txt
SCRIPT
Vagrant.configure("2") do |config|
# TravisCI uses a Trusty Tahr base image (2018-05-26)
config.vm.box = 'ubuntu/trusty64'
config.vm.network 'private_network', type: 'dhcp'
config.vm.synced_folder '.', '/vagrant', type: 'nfs'
config.vm.provider 'virtualbox' do |v|
host = RbConfig::CONFIG['host_os']
# Give VM 1/4 system memory & access to all cpu cores on the host
if host =~ /darwin/
cpus = `sysctl -n hw.ncpu`.to_i
# sysctl returns Bytes and we need to convert to MB
mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
elsif host =~ /linux/
cpus = `nproc`.to_i
# meminfo shows KB and we need to convert to MB
mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4
else
cpus = 2
mem = 1024
end
v.customize ['modifyvm', :id, '--memory', mem]
v.customize ['modifyvm', :id, '--cpus', cpus]
end
config.vm.provision 'shell', inline: $script, privileged: false
end