This repository has been archived by the owner on Nov 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Vagrantfile
executable file
·75 lines (63 loc) · 2.56 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version ">= 1.9"
vmIp = "192.168.50.50"
memory = ( ENV['MEMORY'] || 4096 ).to_i
cpus = ( ENV['CPUS'] || 2 ).to_i
scriptEnableSwap = <<SCRIPT
if grep -q "swapfile" /etc/fstab; then
echo 'swapfile found. No changes made.'
else
echo 'swapfile not found. Adding swapfile.'
fallocate -l 2001M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap defaults 0 0' >> /etc/fstab
fi
SCRIPT
scriptInstallBaseSystem = <<SCRIPT
apt-get install -y mc vim htop ctop git curl resolvconf dnsutils
curl -s -L https://get.docker.com | bash
curl -s -L https://github.com/docker/compose/releases/download/1.11.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
usermod -aG docker vagrant
echo 1 > /proc/sys/net/ipv4/ip_forward
echo '#!/bin/sh -e' > /etc/rc.local
echo 'iptables -A FORWARD -j ACCEPT' | tee -a /etc/rc.local | sh
echo 'exit 0' >> /etc/rc.local
SCRIPT
scriptInstallDockerDns = <<SCRIPT
docker run --restart always -d --name dns-gen --dns=8.8.8.8 --dns=8.8.4.4 -p #{vmIp}:53:53/udp -v /var/run/docker.sock:/var/run/docker.sock oroinc/docker-dns-gen
echo "nameserver #{vmIp}" | tee -a /etc/resolvconf/resolv.conf.d/head
resolvconf -u
SCRIPT
scriptSetupUserEnvironment = <<SCRIPT
sudo -u vagrant ssh-keygen -t rsa -f /home/vagrant/.ssh/id_rsa -P ""
SCRIPT
Vagrant.configure(2) do |config|
config.vm.hostname = "oroenv"
config.vm.provider :virtualbox do |vb, override|
override.vm.box = "bento/ubuntu-16.04" # See for more info https://github.com/chef/bento
vb.gui = false
vb.memory = memory
vb.cpus = cpus
override.vm.network "private_network", ip: vmIp
# Use faster paravirtualized networking
# vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
# vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
end
# avoid possible request "vagrant@127.0.0.1's password:" when "up" and "ssh"
config.ssh.password = "vagrant"
config.vm.provision :shell, :inline => scriptEnableSwap
config.vm.provision :shell, :inline => scriptInstallBaseSystem
config.vm.provision :shell, :inline => scriptInstallDockerDns
config.vm.provision :shell, :inline => scriptSetupUserEnvironment
end
# HOW TO ADD ROUTE TO DOCKER THROUGH VAGRANT VM
# Windows
# route -p ADD 172.0.0.0 MASK 255.0.0.0 192.168.50.50
# OSX
# sudo route -n add -net 172.0.0.0/8 192.168.50.50
# Linux
# sudo route add -net 172.0.0.0/8 gw 192.168.50.50