1
0
mirror of https://github.com/avatao-content/test-tutorial-framework synced 2024-11-15 02:27:18 +00:00
test-tutorial-framework/hack/libhack/baseimage.sh

41 lines
1.1 KiB
Bash
Raw Normal View History

# Requires context:
# - BASEIMAGE_PATH: absolute path of baseimage repo
# - BASEIMAGE_REPO: basename of baseimage repo
2019-09-13 13:44:51 +00:00
BASEIMAGE_NAME="${BASEIMAGE_NAME:-avatao/baseimage-tutorial-framework}"
2018-06-15 13:18:46 +00:00
libhack_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
source "${libhack_dir}/common.sh"
2019-09-30 13:08:04 +00:00
baseimage::assert_exists() {
if [[ ! -d "${BASEIMAGE_PATH}" ]]; then
exit 0
fi
}
2019-09-30 13:08:04 +00:00
baseimage::build_if_exists() {
[[ ! -d "${BASEIMAGE_PATH}" ]] && return ||:
pushd "${BASEIMAGE_PATH}"
2019-09-30 13:08:04 +00:00
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)"
2019-09-30 13:08:04 +00:00
read -p "Tag and push baseimage \"${tag}\"? [y/N]" -r && echo
2018-06-18 12:53:10 +00:00
if [[ $REPLY =~ ^(y|Y|yes|Yes|YES)$ ]]; then
2019-09-30 13:08:04 +00:00
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
}