From ad850c13db6ed4678f20412d7b19b8e7b76467fd Mon Sep 17 00:00:00 2001 From: Steve Worley Date: Wed, 29 Nov 2023 14:49:08 +1000 Subject: [PATCH 1/2] Add latest tag build and push. --- mariadb-image-builder | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mariadb-image-builder b/mariadb-image-builder index 784b66c..6ded960 100644 --- a/mariadb-image-builder +++ b/mariadb-image-builder @@ -162,6 +162,8 @@ BUILDER_DOCKER_HOST=$(projectEnvironmentVariableCheck BUILDER_DOCKER_HOST "${BUI BUILDER_MTK_YAML_BASE64=$(projectEnvironmentVariableCheck BUILDER_MTK_YAML_BASE64 "${BUILDER_MTK_YAML_BASE64}") +# optional +BUILDER_ONLY_LATEST=$(projectEnvironmentVariableCheck BUILDER_ONLY_LATEST "0") # check the pattern if [ -z $BUILDER_BACKUP_IMAGE_NAME ]; then @@ -255,7 +257,7 @@ done # build the image ln -s mariadb.Dockerfile Dockerfile -docker build --network=host --build-arg BUILDER_IMAGE="${BUILDER_IMAGE_NAME}" --build-arg CLEAN_IMAGE="${BUILDER_CLEAN_IMAGE_NAME}" -t ${backup_image_full} . +docker build --network=host --build-arg BUILDER_IMAGE="${BUILDER_IMAGE_NAME}" --build-arg CLEAN_IMAGE="${BUILDER_CLEAN_IMAGE_NAME}" -t ${backup_image_full} -t "${BUILDER_BACKUP_IMAGE_NAME}:latest" . ##### Phase 4: Save new container to registry @@ -275,7 +277,10 @@ echo "=== Phase 4: Save new container to registry ===" echo $BUILDER_REGISTRY_PASSWORD | docker login ${BUILDER_REGISTRY_HOST} -u "$BUILDER_REGISTRY_USERNAME" --password-stdin # Push the image to remote -docker push "${backup_image_full}" +docker push "${BUILDER_BACKUP_IMAGE_NAME}:latest" +if [ "$BUILDER_ONLY_LATEST" == "0" ]; then + docker push "${backup_image_full}" +fi echo echo "========================" From 933438885dff6ff9943cdcb3b5f377c6bf0ce429 Mon Sep 17 00:00:00 2001 From: Steve Worley Date: Thu, 30 Nov 2023 08:39:46 +1000 Subject: [PATCH 2/2] Update the push process. --- mariadb-image-builder | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mariadb-image-builder b/mariadb-image-builder index 6ded960..461748f 100644 --- a/mariadb-image-builder +++ b/mariadb-image-builder @@ -163,7 +163,7 @@ BUILDER_DOCKER_HOST=$(projectEnvironmentVariableCheck BUILDER_DOCKER_HOST "${BUI BUILDER_MTK_YAML_BASE64=$(projectEnvironmentVariableCheck BUILDER_MTK_YAML_BASE64 "${BUILDER_MTK_YAML_BASE64}") # optional -BUILDER_ONLY_LATEST=$(projectEnvironmentVariableCheck BUILDER_ONLY_LATEST "0") +BUILDER_PUSH_TAGS=$(projectEnvironmentVariableCheck BUILDER_PUSH_TAGS "both") # check the pattern if [ -z $BUILDER_BACKUP_IMAGE_NAME ]; then @@ -277,8 +277,11 @@ echo "=== Phase 4: Save new container to registry ===" echo $BUILDER_REGISTRY_PASSWORD | docker login ${BUILDER_REGISTRY_HOST} -u "$BUILDER_REGISTRY_USERNAME" --password-stdin # Push the image to remote -docker push "${BUILDER_BACKUP_IMAGE_NAME}:latest" -if [ "$BUILDER_ONLY_LATEST" == "0" ]; then +if [ "$BUILDER_PUSH_TAGS" == "both" ] || [ "$BUILDER_PUSH_TAGS" == "latest" ]; then + docker push "${BUILDER_BACKUP_IMAGE_NAME}:latest" +fi + +if [ "$BUILDER_PUSH_TAGS" == "both" ] || [ "$BUILDER_PUSH_TAGS" == "default" ]; then docker push "${backup_image_full}" fi