-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
51 lines (41 loc) · 1.55 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Configure number of NGINX websites to create
servers_number = 2
Vagrant.configure(2) do |config|
config.vm.define 'server1' do |server|
server.vm.box = 'boxcutter/ubuntu1604'
server.vm.hostname = 'server1'
server.vm.network 'private_network', ip: '192.168.50.10'
server.vm.provision 'docker' do |docker|
1.upto(servers_number) do |num|
nginx_volumes = %W{
/vagrant/nginx/nginx.conf:/etc/nginx/nginx.conf
/vagrant/nginx/web#{num}:/usr/share/nginx/html
/vagrant/MyCert.pem:/usr/share/nginx/ssl/MyCert.pem
}
docker.run "web#{num}",
image: 'nginx',
args: nginx_volumes.map {|vol| "-v #{vol} " }.join
end
end
docker_network_setup = %Q{
if [[ $(docker network ls | grep "isolated_nw") = "" ]]; then
docker network create -d bridge isolated_nw
fi
}
1.upto(servers_number) do |num|
docker_network_setup << %Q{
if [[ $(docker inspect web#{num} | grep "isolated_nw") = "" ]]; then
docker network connect isolated_nw web#{num}
fi
}
end
server.vm.provision 'shell', inline: docker_network_setup
server.vm.provision 'docker' do |docker|
docker.run "lb1",
image: 'haproxy',
args: '-v /vagrant/MyCert.pem:/usr/local/etc/haproxy/MyCert.pem -v /vagrant/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg -p 80:80 -p 443:443 --net isolated_nw'
end
end
end