From b7788ab862807208482a84b3ae74cc4c673e5149 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 25 Feb 2024 14:10:32 -0500 Subject: [PATCH] fix: correctly use cache volume for herokuish builds Rather than try to mount a directory into the container and use a symlink, directly mount the volume in. Note that this requires deleting the task container prior to continuing in order to ensure the volume isn't still mounted prior to other tasks being executed. --- plugins/app-json/functions.go | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/plugins/app-json/functions.go b/plugins/app-json/functions.go index b5cf991b3..fe24ca885 100644 --- a/plugins/app-json/functions.go +++ b/plugins/app-json/functions.go @@ -47,11 +47,6 @@ func constructScript(command string, shell string, isHerokuishImage bool, isCnbI "if [[ -d '/app/.profile.d' ]]; then", " for file in /app/.profile.d/*; do source $file; done;", "fi;", - - "if [[ -d '/cache' ]]; then", - " rm -rf /tmp/cache ;", - " ln -sf /cache /tmp/cache;", - "fi;", }...) } @@ -67,14 +62,6 @@ func constructScript(command string, shell string, isHerokuishImage bool, isCnbI script = append(script, fmt.Sprintf("%s || exit 1;", command)) - if isHerokuishImage && !isCnbImage { - script = append(script, []string{ - "if [[ -d '/cache' ]]; then", - " rm -f /tmp/cache;", - "fi;", - }...) - } - return []string{shell, "-c", strings.Join(script, " ")} } @@ -164,7 +151,12 @@ func cleanupDeploymentContainer(appName string, containerID string, phase string if phase != "predeploy" { os.Setenv("DOKKU_SKIP_IMAGE_RETIRE", "true") } - return common.PlugnTrigger("scheduler-register-retired", []string{appName, containerID}...) + + if !common.ContainerRemove(containerID) { + return fmt.Errorf("Failed to remove %s execution container", phase) + } + + return nil } func executeScript(appName string, image string, imageTag string, phase string) error { @@ -211,12 +203,6 @@ func executeScript(appName string, image string, imageTag string, phase string) imageSourceType = "pack" } - cacheDir := fmt.Sprintf("%s/cache", common.AppRoot(appName)) - cacheHostDir := fmt.Sprintf("%s/cache", common.AppHostRoot(appName)) - if !common.DirectoryExists(cacheDir) { - os.MkdirAll(cacheDir, 0755) - } - var dockerArgs []string if b, err := common.PlugnTriggerSetup("docker-args-deploy", []string{appName, imageTag}...).SetInput("").Output(); err == nil { words, err := shellquote.Split(strings.TrimSpace(string(b[:]))) @@ -275,7 +261,9 @@ func executeScript(appName string, image string, imageTag string, phase string) } dockerArgs = append(dockerArgs, "--label=dokku_phase_script="+phase) - dockerArgs = append(dockerArgs, "-v", cacheHostDir+":/cache") + if isHerokuishImage && !isCnbImage { + dockerArgs = append(dockerArgs, "-v", fmt.Sprintf("cache-%s:/tmp/cache", appName)) + } if os.Getenv("DOKKU_TRACE") != "" { dockerArgs = append(dockerArgs, "--env", "DOKKU_TRACE="+os.Getenv("DOKKU_TRACE")) }