From 0673fdff2da59873ba1bf7edf59a874b9004cff6 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 11 Feb 2021 07:16:43 -0500 Subject: [PATCH] fix: handle new herokuish image detection in deployment tasks --- plugins/app-json/functions.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/app-json/functions.go b/plugins/app-json/functions.go index 95f6d3f72..c86b78932 100644 --- a/plugins/app-json/functions.go +++ b/plugins/app-json/functions.go @@ -16,7 +16,7 @@ import ( "golang.org/x/sync/errgroup" ) -func constructScript(command string, shell string, isHerokuishImage bool, hasEntrypoint bool) []string { +func constructScript(command string, shell string, isHerokuishImage bool, isCnbImage bool, hasEntrypoint bool) []string { if hasEntrypoint { words, err := shellquote.Split(strings.TrimSpace(command)) if err != nil { @@ -31,7 +31,7 @@ func constructScript(command string, shell string, isHerokuishImage bool, hasEnt script = append(script, "set -x;") } - if isHerokuishImage { + if isHerokuishImage && !isCnbImage { script = append(script, []string{ "if [[ -d '/app' ]]; then", " export HOME=/app;", @@ -60,7 +60,7 @@ func constructScript(command string, shell string, isHerokuishImage bool, hasEnt script = append(script, fmt.Sprintf("%s || exit 1;", command)) - if isHerokuishImage { + if isHerokuishImage && !isCnbImage { script = append(script, []string{ "if [[ -d '/cache' ]]; then", " rm -f /tmp/cache;", @@ -164,7 +164,7 @@ func executeScript(appName string, image string, imageTag string, phase string) common.LogInfo1(fmt.Sprintf("Executing %s task from %s: %s", phase, phaseSource, command)) isHerokuishImage := common.IsImageHerokuishBased(image, appName) - isImageCnbBased := common.IsImageCnbBased(image) + isCnbImage := common.IsImageCnbBased(image) dockerfileEntrypoint := "" dockerfileCommand := "" if !isHerokuishImage { @@ -174,11 +174,13 @@ func executeScript(appName string, image string, imageTag string, phase string) hasEntrypoint := dockerfileEntrypoint != "" dokkuAppShell := getDokkuAppShell(appName) - script := constructScript(command, dokkuAppShell, isHerokuishImage, hasEntrypoint) + script := constructScript(command, dokkuAppShell, isHerokuishImage, isCnbImage, hasEntrypoint) imageSourceType := "dockerfile" if isHerokuishImage { imageSourceType = "herokuish" + } else if isCnbImage { + imageSourceType = "cnb" } cacheDir := fmt.Sprintf("%s/cache", common.AppRoot(appName)) @@ -225,7 +227,7 @@ func executeScript(appName string, image string, imageTag string, phase string) if os.Getenv("DOKKU_TRACE") != "" { dockerArgs = append(dockerArgs, "--env", "DOKKU_TRACE="+os.Getenv("DOKKU_TRACE")) } - if isImageCnbBased { + if isCnbImage { // TODO: handle non-linux lifecycles // Ideally we don't have to override this but `pack` injects the web process // as the default entrypoint, so we need to specify the launcher so the script @@ -254,7 +256,7 @@ func executeScript(appName string, image string, imageTag string, phase string) } commitArgs := []string{"container", "commit"} - if !isHerokuishImage { + if !isHerokuishImage || isCnbImage { if dockerfileEntrypoint != "" { commitArgs = append(commitArgs, "--change", dockerfileEntrypoint) }