-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·71 lines (52 loc) · 1.32 KB
/
run.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
63
64
65
66
67
68
69
70
71
#!/bin/bash
DEPS=(docker find basename git)
verify_deps() {
for e in ${DEPS[*]}; do
CHECK=$(command -v "$e" 2>/dev/null)
if [[ "$CHECK" == "" ]]; then
echo "Looking for installed software, ${DEPS[*]}"
echo "$e not found!" && echo
exit 1
fi
done
}
set_version() {
if [[ $VER == "" ]]; then
VER="latest"
fi
}
main() {
verify_deps
set_version
REPO_NAME=$(basename "$(git rev-parse --show-toplevel)")
case $1 in
build)
sudo docker build --network=host -t "$REPO_NAME":"$VER" .
;;
run)
sudo docker run --network=host -d --name="$REPO_NAME" --restart always "$REPO_NAME":"$VER"
;;
destroy)
sudo docker rm -f "$REPO_NAME"
;;
clean)
find . -name '*.DS_Store' -type f -delete
find . -name '*.log' -type f -delete
find . -name '*.sw[klmnop]' -type f -delete
;;
*)
BANNER="
$0 build,run,destroy,clean: $1 incorrect argument
VER='1.0.0' $0 build # Build image 1.0.0 version
VER='1.0.0' $0 run # Run image 1.0.0 version
$0 build # Build latest version
$0 run # Run latest container
$0 destroy # Destroy running container
$0 clean # Clean project
"
echo "$BANNER"
exit 1
;;
esac
}
main "$1"