reorganized tagging
This commit is contained in:
parent
e768cb5b87
commit
286bfa0248
64
build.sh
64
build.sh
|
@ -86,6 +86,25 @@ SRC_REPO="${SRC_REPO-netbox}"
|
||||||
BRANCH="${1}"
|
BRANCH="${1}"
|
||||||
URL="${URL-https://github.com/${SRC_ORG}/${SRC_REPO}/archive/$BRANCH.tar.gz}"
|
URL="${URL-https://github.com/${SRC_ORG}/${SRC_REPO}/archive/$BRANCH.tar.gz}"
|
||||||
|
|
||||||
|
# Checking which VARIANT to build
|
||||||
|
VARIANT="${VARIANT-main}"
|
||||||
|
if [ "$VARIANT" == "main" ]; then
|
||||||
|
DOCKERFILE="Dockerfile"
|
||||||
|
else
|
||||||
|
DOCKERFILE="Dockerfile.${VARIANT}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fail fast
|
||||||
|
if [ ! -f "${DOCKERFILE}" ]; then
|
||||||
|
echo "🚨 The Dockerfile ${DOCKERFILE} for variant '${VARIANT}' doesn't exist."
|
||||||
|
|
||||||
|
if [ -z "$DEBUG" ]; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "⚠️ Would exit here with code '1', but DEBUG is enabled."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# variables for tagging the docker image
|
# variables for tagging the docker image
|
||||||
DOCKER_ORG="${DOCKER_ORG-netboxcommunity}"
|
DOCKER_ORG="${DOCKER_ORG-netboxcommunity}"
|
||||||
DOCKER_REPO="${DOCKER_REPO-netbox}"
|
DOCKER_REPO="${DOCKER_REPO-netbox}"
|
||||||
|
@ -97,25 +116,20 @@ case "${BRANCH}" in
|
||||||
*)
|
*)
|
||||||
TAG="${TAG-$BRANCH}";;
|
TAG="${TAG-$BRANCH}";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
DOCKER_TAG="${DOCKER_TAG-${DOCKER_ORG}/${DOCKER_REPO}:${TAG}}"
|
DOCKER_TAG="${DOCKER_TAG-${DOCKER_ORG}/${DOCKER_REPO}:${TAG}}"
|
||||||
|
if [ "$VARIANT" != "main" ]; then
|
||||||
# Checking which VARIANT to build
|
|
||||||
VARIANT="${VARIANT-main}"
|
|
||||||
if [ "$VARIANT" == "main" ]; then
|
|
||||||
DOCKERFILE="Dockerfile"
|
|
||||||
else
|
|
||||||
DOCKERFILE="Dockerfile.${VARIANT}"
|
|
||||||
DOCKER_TAG="${DOCKER_TAG}-${VARIANT}"
|
DOCKER_TAG="${DOCKER_TAG}-${VARIANT}"
|
||||||
|
|
||||||
# Fail fast
|
|
||||||
if [ ! -f "${DOCKERFILE}" ]; then
|
|
||||||
echo "🚨 The Dockerfile ${DOCKERFILE} for variant '${VARIANT}' doesn't exist."
|
|
||||||
|
|
||||||
if [ -z "$DEBUG" ]; then
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "⚠️ Would exit here with code '1', but DEBUG is enabled."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "${TAG}" =~ ^v([0-9]+)\.([0-9]+)\.[0-9]+$ ]]; then
|
||||||
|
MAJOR=${BASH_REMATCH[1]}
|
||||||
|
MINOR=${BASH_REMATCH[2]}
|
||||||
|
|
||||||
|
DOCKER_SHORT_TAG="${DOCKER_SHORT_TAG-${DOCKER_ORG}/${DOCKER_REPO}:v${MAJOR}.${MINOR}}"
|
||||||
|
|
||||||
|
if [ "$VARIANT" != "main" ]; then
|
||||||
|
DOCKER_SHORT_TAG="${DOCKER_SHORT_TAG}-${VARIANT}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -162,24 +176,22 @@ if [ "${2}" != "--push-only" ] ; then
|
||||||
echo "🐳 Building the Docker image '${DOCKER_TAG}' from the url '${URL}'."
|
echo "🐳 Building the Docker image '${DOCKER_TAG}' from the url '${URL}'."
|
||||||
$DOCKER_CMD build -t "${DOCKER_TAG}" "${DOCKER_BUILD_ARGS[@]}" "${DOCKER_OPTS[@]}" -f "${DOCKERFILE}" .
|
$DOCKER_CMD build -t "${DOCKER_TAG}" "${DOCKER_BUILD_ARGS[@]}" "${DOCKER_OPTS[@]}" -f "${DOCKERFILE}" .
|
||||||
echo "✅ Finished building the Docker images '${DOCKER_TAG}'"
|
echo "✅ Finished building the Docker images '${DOCKER_TAG}'"
|
||||||
|
|
||||||
|
if [ -n "$DOCKER_SHORT_TAG" ]; then
|
||||||
|
echo "🐳 Tagging image '${DOCKER_SHORT_TAG}'."
|
||||||
|
$DOCKER_CMD tag "${DOCKER_TAG}" "${DOCKER_SHORT_TAG}"
|
||||||
|
echo "✅ Tagged image '${DOCKER_SHORT_TAG}'"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${2}" == "--push" ] || [ "${2}" == "--push-only" ] ; then
|
if [ "${2}" == "--push" ] || [ "${2}" == "--push-only" ] ; then
|
||||||
echo "⏫ Pushing '${DOCKER_TAG}"
|
echo "⏫ Pushing '${DOCKER_TAG}"
|
||||||
$DOCKER_CMD push "${DOCKER_TAG}"
|
$DOCKER_CMD push "${DOCKER_TAG}"
|
||||||
echo "✅ Finished pushing the Docker image '${DOCKER_TAG}'."
|
echo "✅ Finished pushing the Docker image '${DOCKER_TAG}'."
|
||||||
if [[ "${TAG}" =~ ^v([0-9]+)\.([0-9]+)\.[0-9]+$ ]]; then
|
|
||||||
MAJOR=${BASH_REMATCH[1]}
|
if [ -n "$DOCKER_SHORT_TAG" ]; then
|
||||||
MINOR=${BASH_REMATCH[2]}
|
|
||||||
DOCKER_SHORT_TAG="${DOCKER_SHORT_TAG-${DOCKER_ORG}/${DOCKER_REPO}:v${MAJOR}.${MINOR}}"
|
|
||||||
if [ "$VARIANT" != "main" ]; then
|
|
||||||
DOCKER_SHORT_TAG="${DOCKER_SHORT_TAG}-${VARIANT}"
|
|
||||||
fi
|
|
||||||
echo "⏫ Pushing '${DOCKER_SHORT_TAG}'"
|
echo "⏫ Pushing '${DOCKER_SHORT_TAG}'"
|
||||||
$DOCKER_CMD tag "${DOCKER_TAG}" "${DOCKER_SHORT_TAG}"
|
|
||||||
$DOCKER_CMD push "${DOCKER_SHORT_TAG}"
|
$DOCKER_CMD push "${DOCKER_SHORT_TAG}"
|
||||||
echo "✅ Finished pushing the Docker image '${DOCKER_SHORT_TAG}'."
|
echo "✅ Finished pushing the Docker image '${DOCKER_SHORT_TAG}'."
|
||||||
else
|
|
||||||
echo "☇ No version tag detected; skipping short tag"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue