This repository was archived by the owner on Feb 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·69 lines (47 loc) · 1.35 KB
/
build.sh
File metadata and controls
executable file
·69 lines (47 loc) · 1.35 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
#!/usr/bin/env bash
set -o errexit
## PRE-RUN SETUP & CONFIGURATION
########################################
SCRIPT_DIR="$(dirname $(readlink -f ${0}))"
IMAGE_NAME="theinnercircle/icbot"
TAG="$(grep 'FROM phlak/hangoutsbot' Dockerfile | awk -F : '{print $2}')"
## SCRIPT USAGE
########################################
function usageShort() {
echo "Usage: $(basename ${0}) [OPTIONS]"
}
function usageLong() {
usageShort
cat <<-EOF
OPTIONS:
-h, --help Print this help dialogue
-p, --purge Purge the image after build
EOF
}
## OPTION / PARAMATER PARSING
########################################
PARSED_OPTIONS=$(getopt -n "${0}" -o hp -l "help,purge" -- "$@")
eval set -- "${PARSED_OPTIONS}"
while true; do
case "${1}" in
-h|--help) usageLong; exit ;;
-p|--purge) PURGE=true; shift ;;
--) shift; break ;;
esac
done
## SCRIPT FUNCTIONS
########################################
function buildImage() {
docker build --force-rm --pull --tag ${IMAGE_NAME}:${TAG} ${SCRIPT_DIR}
}
function purgeImage() {
docker rmi --force ${IMAGE_NAME}:${TAG}
echo "Purged image: ${IMAGE_NAME}:${TAG}"
}
function main() {
buildImage; [[ "${PURGE}" == true ]] && purgeImage
echo "Successfully built ${IMAGE_NAME}:${TAG}"
}
# MAKE IT SO
########################################
main