Add labels for all variants

When we don't set the --label argument on the commandline for all
build variants we lose them in the image.
This also prints out the labes on image push.
This commit is contained in:
Tobias Genannt 2020-04-04 10:14:36 +02:00
parent 23e2da52f8
commit 26d08302e3

View file

@ -247,7 +247,6 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
fi fi
# --label # --label
if [ "${DOCKER_TARGET}" == "main" ]; then
DOCKER_BUILD_ARGS+=( DOCKER_BUILD_ARGS+=(
--label "ORIGINAL_TAG=${TARGET_DOCKER_TAG}" --label "ORIGINAL_TAG=${TARGET_DOCKER_TAG}"
@ -270,7 +269,6 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
--label "NETBOX_GIT_URL=${NETBOX_GIT_URL}" --label "NETBOX_GIT_URL=${NETBOX_GIT_URL}"
) )
fi fi
fi
# --build-arg # --build-arg
DOCKER_BUILD_ARGS+=( --build-arg "NETBOX_PATH=${NETBOX_PATH}" ) DOCKER_BUILD_ARGS+=( --build-arg "NETBOX_PATH=${NETBOX_PATH}" )
@ -298,7 +296,9 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
# Pushing the docker images if either `--push` or `--push-only` are passed # Pushing the docker images if either `--push` or `--push-only` are passed
### ###
if [ "${2}" == "--push" ] || [ "${2}" == "--push-only" ] ; then if [ "${2}" == "--push" ] || [ "${2}" == "--push-only" ] ; then
echo "⏫ Pushing '${TARGET_DOCKER_TAG}" echo "⏫ Inspecting labels on '${TARGET_DOCKER_TAG}'"
$DRY docker inspect "${TARGET_DOCKER_TAG}" --format "{{json .Config.Labels}}"
echo "⏫ Pushing '${TARGET_DOCKER_TAG}'"
$DRY docker push "${TARGET_DOCKER_TAG}" $DRY docker push "${TARGET_DOCKER_TAG}"
echo "✅ Finished pushing the Docker image '${TARGET_DOCKER_TAG}'." echo "✅ Finished pushing the Docker image '${TARGET_DOCKER_TAG}'."