addet build script

This commit is contained in:
pika 2025-04-06 15:29:14 +02:00
parent 02b95c1abe
commit 111ceb87a3

71
build.sh Executable file
View file

@ -0,0 +1,71 @@
#!/usr/bin/env bash
# ─< 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"
}
image=docker/caddy
domain=git.k4li.de
tag=latest
container="${domain}/${image}:${tag}"
askToPush() {
echo_info "Do you want to push directly to $domain?"
read -r push_
case "$push_" in
[yY])
push=true
;;
[nN])
push=false
;;
*)
echo_warning "You entered something wrong!"
askToPush
;;
esac
if $push; then
docker push "$container"
fi
}
if ! command_exists docker; then
echo_error "Docker does not exist!"
exit 1
fi
[[ ! -e ./Dockerfile ]] &&
echo_error "Dockerfile does not exist" &&
exit 1
docker build -t "$container" .
askToPush