test-tutorial-framework/hack/libhack/baseimage.sh

41 lines
1.1 KiB
Bash

# Requires context:
# - BASEIMAGE_PATH: absolute path of baseimage repo
# - BASEIMAGE_REPO: basename of baseimage repo
BASEIMAGE_NAME="${BASEIMAGE_NAME:-avatao/baseimage-tutorial-framework}"
libhack_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
source "${libhack_dir}/common.sh"
baseimage::assert_exists() {
if [[ ! -d "${BASEIMAGE_PATH}" ]]; then
exit 0
fi
}
baseimage::build_if_exists() {
[[ ! -d "${BASEIMAGE_PATH}" ]] && return ||:
pushd "${BASEIMAGE_PATH}"
local tag
tag="${BASEIMAGE_NAME}:$(releasename)"
docker build -t "${tag}" .
docker tag "${tag}" "${BASEIMAGE_NAME}:latest"
popd
}
baseimage::release() {
pushd "${BASEIMAGE_PATH}"
local tag
tag="$(releasename)"
read -p "Tag and push baseimage \"${tag}\"? [y/N]" -r && echo
if [[ $REPLY =~ ^(y|Y|yes|Yes|YES)$ ]]; then
printf "Pushing git tag to upstream...\n"
tag="${tag}" description="${tag}" force_push_tag
printf "\nPushing image to DockerHub...\n"
docker push "${BASEIMAGE_NAME}:${tag}"
docker push "${BASEIMAGE_NAME}:latest"
fi
popd
}