forked from desiredState/IPFSStreamingVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·70 lines (57 loc) · 1.55 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -e
function usage {
cat <<EOF
usage: factory [-h] {build,test,push,all} ...
positional arguments:
{build,test,push,all}
build build the Docker Image
push push the Docker Image
optional arguments:
-h, --help display this help message
EOF
}
function check_deps {
# Dependencies which should be in PATH.
DEPS=( 'docker' )
for i in "${DEPS[@]}"; do
if ! hash "${i}" 2>/dev/null; then
echo -e "${RED}BUILD > "${i}" is required. Please install it then try again.${NONE}"
exit 1
fi
done
}
function build {
# Build Docker Image.
echo -e "${MAGENTA}BUILD > Building the ${NAMESPACE}/${IMAGE}:${TAG} Docker Image...${NONE}"
docker build -t "${NAMESPACE}/${IMAGE}:${TAG}" .
echo -e "${GREEN}BUILD > OK.${NONE}"
}
function push {
# Push Docker Image.
echo -e "${MAGENTA}BUILD > Pushing the ${NAMESPACE}/${IMAGE}:${TAG} Docker Image...${NONE}"
docker push "${NAMESPACE}/${IMAGE}:${TAG}"
echo -e "${GREEN}BUILD > OK.${NONE}"
}
# Environment variable overrides.
export NAMESPACE=${NAMESPACE:='desiredstate'}
export IMAGE=${IMAGE:='ipfsstreamingvideo'}
export TAG=${VERSION:='latest'}
export UPDATE=${UPDATE:=false} # false as we're building the Image locally.
MAGENTA=$(tput setaf 5)
GREEN=$(tput setaf 2)
RED=$(tput setaf 1)
NONE=$(tput sgr 0)
check_deps
case $1 in
build)
build
;;
push)
push
;;
*)
usage
exit 1
esac
echo -e "${GREEN}BUILD > Finished.${NONE}"