-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup-docker.sh
executable file
·61 lines (52 loc) · 1.69 KB
/
setup-docker.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
HAPROXY_CONFIG_VERSION=2.0.0
TLD=test
if [ "$(uname)" == "Darwin" ]; then
DNSPORT=5300
sudo mkdir -p /etc/resolver
sudo rm /etc/resolver/${TLD}
sudo touch /etc/resolver/${TLD}
echo 'nameserver 127.0.0.1' | sudo tee -a /etc/resolver/${TLD} > /dev/null
echo 'port 5300' | sudo tee -a /etc/resolver/${TLD} > /dev/null
# start dnsmasq
echo "== Starting dnsmasq ..."
docker stop dnsmasq || true && docker rm dnsmasq || true
docker run -d \
--name dnsmasq \
--restart always \
-p $DNSPORT:53/tcp \
-p $DNSPORT:53/udp \
--cap-add NET_ADMIN \
andyshinn/dnsmasq \
--address=/${TLD}/127.0.0.1
# Setup NFS
U=`id -u`
G=`id -g`
echo "== Setting up nfs..."
LINE="/Users -alldirs -mapall=$U:$G localhost"
FILE=/etc/exports
sudo cp /dev/null $FILE
grep -qF -- "$LINE" "$FILE" || sudo echo "$LINE" | sudo tee -a $FILE > /dev/null
LINE="nfs.server.mount.require_resv_port = 0"
FILE=/etc/nfs.conf
grep -qF -- "$LINE" "$FILE" || sudo echo "$LINE" | sudo tee -a $FILE > /dev/null
echo "== Restarting nfsd..."
sudo nfsd restart
else
echo "Please add your dev hosts to /etc/hosts"
fi
echo "== Building multibasebox image ..."
docker pull factorial/haproxy-config:${HAPROXY_CONFIG_VERSION}
docker build --build-arg HAPROXY_CONFIG_VERSION=$HAPROXY_CONFIG_VERSION -t factorial/multibasebox:${HAPROXY_CONFIG_VERSION} .
# start haproxy
echo "== Starting haproxy ..."
docker stop haproxy || true && docker rm haproxy || true
docker run -d \
-p 80:80 \
-p 443:443 \
-p 1936:1936 \
--privileged \
--restart always \
--volume=/var/run/docker.sock:/var/run/docker.sock \
--name=haproxy \
factorial/multibasebox:${HAPROXY_CONFIG_VERSION}