54 lines
1.4 KiB
Bash
Executable file
54 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
IMAGE_NAME=homedocs
|
|
TAG=latest
|
|
|
|
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
|
command_exists() {
|
|
command -v "$@" >/dev/null 2>&1
|
|
}
|
|
|
|
# ─< ANSI color codes >───────────────────────────────────────────────────────────────────
|
|
RED='\033[0;31m'
|
|
CYAN='\033[0;36m'
|
|
YELLOW='\033[0;33m'
|
|
LIGHT_GREEN='\033[0;92m'
|
|
BOLD='\033[1m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo_error() {
|
|
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
|
}
|
|
|
|
echo_info() {
|
|
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
|
}
|
|
|
|
echo_warning() {
|
|
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
|
}
|
|
|
|
echo_note() {
|
|
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
|
}
|
|
|
|
checks() {
|
|
if ! command_exists docker; then
|
|
echo_error "Docker command does not exist! Please install docker to continue building!"
|
|
return 1
|
|
fi
|
|
|
|
if [[ ! -e ./Dockerfile ]]; then
|
|
echo_error "There is no Dockerfile in the current directory.."
|
|
echo_error "Be sure to execute the script in the project path like: ./src/build.sh"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
build() {
|
|
docker build -t "${IMAGE_NAME}:${TAG}" .
|
|
}
|
|
|
|
if checks; then
|
|
build
|
|
fi
|