Repository navigation
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·127 lines (98 loc) · 2.29 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·127 lines (98 loc) · 2.29 KB
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
#!/bin/bash
function sep1() {
echo "==========================================================================================="
}
function sep2() {
echo "----------------------------------------------------------------------"
}
# Prints out the current state of docker disk usage, containers, images, volumes, and networks
function currstate() {
sep1
sep1
echo "# DOCKER SYSTEM DF (DISK USAGE)"
docker system df
sep2
echo "# DOCKER CONTAINER LS"
docker container ls
sep2
echo "# DOCKER IMAGE LS"
docker image ls
sep2
echo "# DOCKER VOLUME LS"
docker volume ls
sep2
echo "# DOCKER NETWORK LS"
docker network ls
sep2
echo "# DOCKER PS"
docker ps
sep1
sep1
}
# Cleans up the entire repository and submodules, then checks out the main branch
function cleanreset() {
sep1
sep1
echo "# GIT CONFIG"
git config --global submodule.recurse true
git config --global status.submoduleSummary true
git config --global diff.submodule diff
sep1
echo "# GIT STATUS"
git status
sep1
echo "# GIT CLEAN RESET"
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
sep1
echo "# GIT CHECKOUT MAIN"
git checkout main
sep1
echo "# GIT PULL"
git pull
sep1
echo "# GIT STATUS"
git status
sep1
sep1
}
################################################################################
# STEP 1. CLEAN EVERYTHING
################################################################################
# If the first argument is `clean-reset`, run the cleanreset function
if [ "$1" == "clean-reset" ]; then
cleanreset
exit 0
fi
################################################################################
# STEP 2. STOP ALL CURRENT CONTAINERS THEN BUILD & START NEW CONTAINERS
################################################################################
currstate
echo ""
echo ""
sep1
sep1
echo "# DOWN..."
sudo docker-compose down --rmi=all --volumes --remove-orphans
sep2
echo "# PRUNE..."
sudo docker system prune -af --volumes
sep1
sep1
echo ""
echo ""
currstate
echo ""
echo ""
sep1
sep1
echo "# UP..."
sudo docker-compose -f docker-compose.production.yml up --build -d || exit 1
sep1
sep1
echo ""
echo ""
currstate