From a71e4219be78457c2b5a2e453e34a8b0bac344c2 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 9 Aug 2022 02:11:32 -0400 Subject: [PATCH] fix: set the correct image source type based on label We also have a special carveout for herokuish as folks may deploy built images with it. --- plugins/common/functions | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/plugins/common/functions b/plugins/common/functions index 826524ab4..e2abf8bbf 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -330,6 +330,29 @@ get_running_image_tag() { echo "$IMAGE_TAG" } +get_image_builder_type() { + declare desc="returns the image builder_type" + declare IMAGE="$1" APP="$2" + + if [[ -z "$IMAGE" ]]; then + echo "dockerfile" + return + fi + + BUILDER_TYPE="$("$DOCKER_BIN" image inspect --format '{{ index .Config.Labels "com.dokku.builder-type" }}' "$IMAGE")" + if [[ -n "$BUILDER_TYPE" ]]; then + echo "$BUILDER_TYPE" + return + fi + + if is_image_herokuish_based "$IMAGE" "$APP"; then + echo "herokuish" + return + fi + + echo "dockerfile" +} + is_image_cnb_based() { declare desc="returns true if app image is based on cnb" declare IMAGE="$1" @@ -662,10 +685,8 @@ release_and_deploy() { local DOKKU_DOCKERFILE_PORTS if verify_image "$IMAGE"; then - if is_image_herokuish_based "$IMAGE" "$APP"; then - local IMAGE_SOURCE_TYPE="herokuish" - else - local IMAGE_SOURCE_TYPE="dockerfile" + IMAGE_SOURCE_TYPE="$(get_image_builder_type "$IMAGE" "$APP")" + if [[ "$IMAGE_SOURCE_TYPE" == "dockerfile" ]]; then DOKKU_DOCKERFILE_PORTS=$(config_get "$APP" DOKKU_DOCKERFILE_PORTS || true) if [[ -z "$DOKKU_DOCKERFILE_PORTS" ]]; then local DOCKER_IMAGE_PORTS=$(get_exposed_ports_from_image "$IMAGE")