-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVagrantfile
141 lines (118 loc) · 5.92 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Copyright (c) 2015 SIL International
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
required_plugins = %w( vagrant-vbguest vagrant-disksize )
_retry = false
required_plugins.each do |plugin|
unless Vagrant.has_plugin? plugin
system "vagrant plugin install #{plugin}"
_retry=true
end
end
if (_retry)
exec "vagrant " + ARGV.join(' ')
end
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu/xenial64"
config.disksize.size = "20GB"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
#config.vm.network "private_network", ip: "192.168.70.249", nic_type: "virtio"
# These lines override a virtual NIC that the AlbanMontaigu/boot2docker box
# creates by default. If you need to change the the box's IP address (which
# is necessary to run separate, simulataneous instances of this Vagrantfile),
# do it here.
config.vm.provider "virtualbox" do |v, override|
# Enable gui for troubleshooting with boot
# v.gui = true
# Create a private network for accessing VM without NAT
override.vm.network "private_network", ip: "192.168.70.121"
end
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# Synced folders for container data.
# Note: override mount_options on default sync folder to fix permissions
config.vm.synced_folder ".", "/vagrant",
# 33 is the www-data user/group in the ubuntu container
mount_options: ["uid=33","gid=33","fmode=755","dmode=755"]
config.vm.provider "virtualbox" do |vb|
# Customize the amount of memory on the VM: database needs more memory
vb.memory = "2048"
# A fix for speed issues with DNS resolution:
# http://serverfault.com/questions/453185/vagrant-virtualbox-dns-10-0-2-3-not-working?rq=1
#vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
# Set the timesync threshold to 59 seconds, instead of the default 20 minutes.
# 59 seconds chosen to ensure SimpleSAML never gets too far out of date.
vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 59000]
end
# This provisioner runs on the first `vagrant up`.
config.vm.provision "install", type: "shell", inline: <<-SHELL
# Add Docker apt repository
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo sh -c 'echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list'
sudo apt-get update -y
# Uninstall old lxc-docker
apt-get purge lxc-docker
apt-cache policy docker-engine
# Install docker and dependencies
sudo apt-get install -y linux-image-extra-$(uname -r)
sudo apt-get install -y docker-engine
# Add user vagrant to docker group
sudo groupadd docker
sudo usermod -aG docker vagrant
# Install Docker Compose
curl -sS -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
echo 'export DOCKER_UIDGID=0:0' >> /home/vagrant/.profile
echo 'cd /vagrant' >> /home/vagrant/.profile
SHELL
# This provisioner runs on every `vagrant reload' (as well as the first
# `vagrant up`), reinstalling from local directories
config.vm.provision "recompose", type: "shell",
run: "always", inline: <<-SHELL
# Run docker-compose (which will update preloaded images, and
# pulls any images not preloaded)
cd /vagrant
# Start services
DOCKER_UIDGID="0:0" make
SHELL
end