1
0
mirror of https://github.com/avatao-content/test-tutorial-framework synced 2024-11-14 22:47:18 +00:00
test-tutorial-framework/hack/libhack/baseimage.sh
2019-09-30 15:08:04 +02:00

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
}