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

49 lines
1.4 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"
baseimage::build() {
baseimage::assert_exists
pushd "${BASEIMAGE_PATH}"
2019-09-30 13:08:04 +00:00
local tag
tag="${BASEIMAGE_NAME}:$(releasename)"
docker build --build-arg FRONTEND_VERSION="${frontend_version}" \
-t "${tag}" \
.
2019-09-30 13:08:04 +00:00
docker tag "${tag}" "${BASEIMAGE_NAME}:latest"
popd
}
baseimage::assert_exists() {
2019-11-12 12:31:56 +00:00
if ! baseimage::check_exists; then
printf "Cannot find baseimage at ${BASEIMAGE_PATH}!\n"
exit 1
fi
}
2019-11-12 12:31:56 +00:00
baseimage::check_exists() {
[[ -d "${BASEIMAGE_PATH}" ]]
}
baseimage::release() {
baseimage::assert_exists
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
}