forked from yeg-relief/youcanbenefit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·87 lines (77 loc) · 1.87 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
root="$(git rev-parse --show-toplevel)"
#hash="$(git rev-parse HEAD)"
hash="$(date +%F)"
tag=hash
action="help"
echo "Project root is $root"
images=()
build_frontend() {
echo "Building frontend Docker image"
cd "$root/frontend"
docker build --tag "cityofedmonton/ycb-frontend:$tag" .
images+=("cityofedmonton/ycb-frontend:$tag")
#docker tag "cityofedmonton/ycb-frontend:$hash" "cityofedmonton/ycb-frontend:$tag"
}
build_backend() {
echo "Building backend Docker image"
cd "$root/backend"
docker build --tag "cityofedmonton/ycb-backend:$tag" .
images+=("cityofedmonton/ycb-backend:$tag")
#docker tag "cityofedmonton/ycb-backend:$hash" "cityofedmonton/ycb-backend:$tag"
}
print_help() {
echo "Helps with build and pushing Docker images for You Can Benefit"
echo " "
echo "$package [options] application [arguments]"
echo " "
echo "options:"
echo "-h, --help show brief help"
echo "frontend build the frontend image"
echo "backend build the backend image"
echo "-p, --push also attempt to push the images. Must come after frontend and backend."
echo "-t, --tag tag of image"
exit 0
}
push_images(){
docker push "cityofedmonton/ycb-frontend:$tag"
docker push "cityofedmonton/ycb-backend:$tag"
}
while test $# -gt 0; do
case "$1" in
-h | --help)
action="help"
;;
frontend)
action="build_frontend"
shift
;;
backend)
action="build_backend"
shift
;;
-t | --tag)
tag="$2"
shift
shift
;;
push)
action="push"
shift
;;
*)
echo "Unknown option $1"
break
;;
esac
done
echo "$action $tag"
if [ "$action" == "build_frontend" ]; then
build_frontend
elif [ "$action" == "build_backend" ]; then
build_backend
elif [ "$action" = "push" ]; then
push_images
else
print_help
fi