# 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::build_if_exists() { [[ ! -d "${BASEIMAGE_PATH}" ]] && return ||: baseimage::build } baseimage::build() { baseimage::assert_exists pushd "${BASEIMAGE_PATH}" local tag tag="${BASEIMAGE_NAME}:$(releasename)" docker build --build-arg FRONTEND_VERSION="${frontend_version}" \ -t "${tag}" \ . docker tag "${tag}" "${BASEIMAGE_NAME}:latest" popd } baseimage::assert_exists() { if [[ ! -d "${BASEIMAGE_PATH}" ]]; then printf "Cannot find baseimage at ${BASEIMAGE_PATH}!\n" exit 1 fi } baseimage::release() { baseimage::assert_exists 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 }