-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathprovision.sh
executable file
·37 lines (29 loc) · 1.33 KB
/
provision.sh
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
#!/bin/bash
# Update the package index
echo "************************ apt-get update ************************"
sudo apt-get update
# Install util packages
echo "************************ install git ************************"
sudo apt-get install git socat -y
# Install Docker
echo "************************ install docker ************************"
wget -qO- https://get.docker.com/ | sh
sudo usermod -aG docker vagrant
# Build the haproxy image
echo "************************ build haproxy image ************************"
cd /vagrant/ha
sudo docker build -t softengheigvd/ha .
# Build the webapp image
echo "************************ build webapp image ************************"
cd /vagrant/webapp
sudo docker build -t softengheigvd/webapp .
# Run two webapps
echo "************************ run webapps ************************"
sudo docker rm -f s1 2>/dev/null || true
sudo docker rm -f s2 2>/dev/null || true
sudo docker run -d --restart=always -e "TAG=s1" --name s1 softengheigvd/webapp
sudo docker run -d --restart=always -e "TAG=s2" --name s2 softengheigvd/webapp
# Run load balancer
echo "************************ run haproxy ************************"
sudo docker rm -f ha 2>/dev/null || true
sudo docker run -d -p 80:80 -p 1936:1936 -p 9999:9999 --restart=always -v /supervisor:/supervisor --link s1 --link s2 --name ha softengheigvd/ha