-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·62 lines (42 loc) · 1.19 KB
/
deploy.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
61
62
#!/bin/sh
echo "\n\n1. Applying configuration from env.sh\n"
if [ -f env.sh ]; then
./env.sh
else
echo "--> No configuration found"
fi
echo "\n\n2. Creating global networks\n"
NETWORKS=$(docker network ls)
echo "Creating proxy network"
if docker network ls | grep -q "proxy\s*overlay"; then
echo "--> proxy network already exists"
else
docker network create -d overlay proxy
fi
echo "Creating database network"
if docker network ls | grep -q "database\s*overlay"; then
echo "--> database network already exists"
else
docker network create -d overlay database
fi
echo "\n\n3. Stopping removed stacks\n"
if [ -f deployments.txt ]; then
while read p; do
if [ ! -d $p ]; then
echo "--> Removing ${p}"
docker stack rm "${p}"
fi
done < deployments.txt
rm deployments.txt
fi
echo "\n\n4. Deploying current stacks\n"
for D in *; do
if [ -d "${D}" ]; then
echo "--> Deploying ${D}"
docker stack deploy -c "./${D}/docker-compose.yml" "${D}" --with-registry-auth
echo "\n"
echo "${D}" >> deployments.txt
fi
done
# Add an empty line at the end of cached deployments.txt
echo "" >> deployments.txt