2018-06-12 12:31:27 +00:00
|
|
|
# Requires context:
|
|
|
|
# - BASEIMAGE_PATH: absolute path of baseimage repo
|
2018-06-19 12:23:48 +00:00
|
|
|
# - BASEIMAGE_REPO: basename of baseimage repo
|
2018-06-12 12:31:27 +00:00
|
|
|
|
2019-09-13 13:44:51 +00:00
|
|
|
BASEIMAGE_NAME="${BASEIMAGE_NAME:-avatao/baseimage-tutorial-framework}"
|
2018-06-15 13:18:46 +00:00
|
|
|
|
2018-06-12 12:31:27 +00:00
|
|
|
libhack_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
|
|
|
source "${libhack_dir}/common.sh"
|
|
|
|
|
|
|
|
|
2019-09-30 13:08:04 +00:00
|
|
|
baseimage::build_if_exists() {
|
|
|
|
[[ ! -d "${BASEIMAGE_PATH}" ]] && return ||:
|
2019-10-31 14:17:27 +00:00
|
|
|
baseimage::build
|
|
|
|
}
|
|
|
|
|
|
|
|
baseimage::build() {
|
|
|
|
baseimage::assert_exists
|
2018-06-12 12:31:27 +00:00
|
|
|
pushd "${BASEIMAGE_PATH}"
|
2019-09-30 13:08:04 +00:00
|
|
|
local tag
|
|
|
|
tag="${BASEIMAGE_NAME}:$(releasename)"
|
2019-10-31 14:17:27 +00:00
|
|
|
docker build --build-arg FRONTEND_VERSION="${frontend_version}" \
|
|
|
|
-t "${tag}" \
|
|
|
|
.
|
2019-09-30 13:08:04 +00:00
|
|
|
docker tag "${tag}" "${BASEIMAGE_NAME}:latest"
|
2018-06-12 12:31:27 +00:00
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
2019-10-31 14:17:27 +00:00
|
|
|
baseimage::assert_exists() {
|
|
|
|
if [[ ! -d "${BASEIMAGE_PATH}" ]]; then
|
|
|
|
printf "Cannot find baseimage at ${BASEIMAGE_PATH}!\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-06-12 12:31:27 +00:00
|
|
|
baseimage::release() {
|
2019-10-31 14:17:27 +00:00
|
|
|
baseimage::assert_exists
|
2018-06-12 12:31:27 +00:00
|
|
|
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"
|
2018-06-12 12:31:27 +00:00
|
|
|
fi
|
|
|
|
popd
|
|
|
|
}
|