imagebuilder: optionally support custom tag names
This commit is contained in:
parent
c2cff1c2fc
commit
1010751721
1 changed files with 11 additions and 6 deletions
|
@ -58,8 +58,8 @@ if [[ -z "${subcommand}" ]]; then
|
||||||
echo -e " ${HC}${FGRN}./imagebuilder.sh${RS} ${CACTION}{action}${RS} ${LC}[${RS}${CARG}{arguments}${RS}${LC}]${RS}" >&2;
|
echo -e " ${HC}${FGRN}./imagebuilder.sh${RS} ${CACTION}{action}${RS} ${LC}[${RS}${CARG}{arguments}${RS}${LC}]${RS}" >&2;
|
||||||
echo -e "" >&2;
|
echo -e "" >&2;
|
||||||
echo -e "${CHEADING}Actions:${RS}" >&2;
|
echo -e "${CHEADING}Actions:${RS}" >&2;
|
||||||
echo -e " ${CACTION}build${RS} ${CARG}{imagename}${RS}" >&2;
|
echo -e " ${CACTION}build${RS} ${CARG}{imagename}${RS} [${CARG}{imagetag}${RS}]" >&2;
|
||||||
echo -e " Build the given image and upload it to the docker registry" >&2;
|
echo -e " Build the given image and upload it to the docker registry, optionally assigning a custom tag name" >&2;
|
||||||
echo -e " ${CACTION}list${RS}" >&2;
|
echo -e " ${CACTION}list${RS}" >&2;
|
||||||
echo -e " List available images" >&2;
|
echo -e " List available images" >&2;
|
||||||
echo -e "" >&2;
|
echo -e "" >&2;
|
||||||
|
@ -99,6 +99,7 @@ case "${subcommand}" in
|
||||||
# ██████ ██████ ██ ███████ ██████
|
# ██████ ██████ ██ ███████ ██████
|
||||||
build)
|
build)
|
||||||
imagename="${1}";
|
imagename="${1}";
|
||||||
|
imagetag="${2}";
|
||||||
|
|
||||||
if [[ -z "${imagename}" ]]; then
|
if [[ -z "${imagename}" ]]; then
|
||||||
echo "Error: No image name specified.":
|
echo "Error: No image name specified.":
|
||||||
|
@ -117,6 +118,12 @@ case "${subcommand}" in
|
||||||
exit 3;
|
exit 3;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Determine the fully qualified tag that we're going to push to
|
||||||
|
docker_tag="${IMAGEBUILDER_REGISTRY}/${imagename}";
|
||||||
|
if [[ ! -z "${imagetag}" ]]; then
|
||||||
|
docker_tag="${docker_tag}:${imagetag}";
|
||||||
|
fi
|
||||||
|
|
||||||
imagetype="$(tr -d "[:blank:]" <"${imagedir}/type.txt")";
|
imagetype="$(tr -d "[:blank:]" <"${imagedir}/type.txt")";
|
||||||
|
|
||||||
case "${imagetype}" in
|
case "${imagetype}" in
|
||||||
|
@ -139,7 +146,6 @@ case "${subcommand}" in
|
||||||
task_end "$?";
|
task_end "$?";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker_tag="${IMAGEBUILDER_REGISTRY}/${imagename}";
|
|
||||||
task_begin "Building docker image";
|
task_begin "Building docker image";
|
||||||
echo "Tag: ${docker_tag}";
|
echo "Tag: ${docker_tag}";
|
||||||
execute docker build --no-cache --pull --tag "${docker_tag}" --build-arg "REPO_LOCATION=${IMAGEBUILDER_REGISTRY}/" .;
|
execute docker build --no-cache --pull --tag "${docker_tag}" --build-arg "REPO_LOCATION=${IMAGEBUILDER_REGISTRY}/" .;
|
||||||
|
@ -194,12 +200,11 @@ case "${subcommand}" in
|
||||||
|
|
||||||
task_begin "Importing resulting image into Docker";
|
task_begin "Importing resulting image into Docker";
|
||||||
image_filepath="$(find "${output_dir}" -iname "*.tar.gz" -printf '%p' -quit)";
|
image_filepath="$(find "${output_dir}" -iname "*.tar.gz" -printf '%p' -quit)";
|
||||||
docker_tag="$(docker import - <"${image_filepath}")";
|
docker_tag_local="$(docker import - <"${image_filepath}")";
|
||||||
task_end "$?";
|
task_end "$?";
|
||||||
|
|
||||||
task_begin "Tagging and pushing to registry";
|
task_begin "Tagging and pushing to registry";
|
||||||
docker_tag_push="${IMAGEBUILDER_REGISTRY}/${imagename}"
|
execute docker tag "${docker_tag_local}" "${docker_tag}";
|
||||||
execute docker tag "${docker_tag}" "${docker_tag_push}";
|
|
||||||
execute docker push "${docker_tag_push}";
|
execute docker push "${docker_tag_push}";
|
||||||
task_end "$?";
|
task_end "$?";
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue