-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·49 lines (40 loc) · 838 Bytes
/
build.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
#!/bin/sh
BUILD_ID=$1
info() {
echo """
This is a containerised NodeJS Application Webserver
"""
}
cleanup() {
echo "Remove dorment containers"
if [ -n "$(docker ps -a -q | head -n 1)" ]; then
docker stop "$(docker ps -a -q)" || true
docker rm -f "$(docker ps -a -q)" || true
else
echo "There is no dorment containers"
fi
}
delete() {
echo "Remove dorment images"
if [ -n "$(docker images -a -q | head -n 1)" ]; then
docker rmi -f "$(docker images -a -q)" || true
else
echo "There is no dorment images"
fi
}
build() {
echo "Building image"
docker build --build-arg "BUILD_ID=${BUILD_ID}" -t docker.io/saidsef/node-webserver .
}
push() {
echo "Pushing image to docker hub"
docker push docker.io/saidsef/node-webserver
echo $?
}
main() {
info
cleanup
build
push
}
main