forked from chriha/docker-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·27 lines (21 loc) · 982 Bytes
/
build
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
#!/usr/bin/env bash
readonly RED="$(tput setaf 1)"
readonly GREEN="$(tput setaf 2)"
readonly YELLOW="$(tput setaf 3)"
readonly BLUE="$(tput setaf 4)"
readonly BOLD="$(tput bold)"
readonly NORMAL="$(tput sgr0)"
readonly CLEAR_LINE="\r\033[K"
[ -z "$1" ] || [ -z "$2" ] && printf "${RED}Please specify what to build and which version.${NORMAL}\n" && exit
[ ! -d "$1" ] && printf "${RED}Unable to find '$1'.${NORMAL}\n" && exit
[ ! -d "$1/$2" ] && printf "${RED}Unable to find version '$2' for '$1'${NORMAL}.\n" && exit
printf "${YELLOW}Starting build ...${NORMAL}\n"
printf "${YELLOW}----------------------------------------${NORMAL}\n"
sleep 2
if ( docker build --no-cache -f "$1/$2/Dockerfile" -t "chriha/$1:$2" "$1/$2/." ); then
printf "${GREEN}----------------------------------------${NORMAL}\n"
printf "${GREEN}Finished!${NORMAL}\n"
else
printf "${RED}----------------------------------------${NORMAL}\n"
printf "${RED}Finished with errors!${NORMAL}\n"
fi