From 9d711cbb4472f41516d699cc86565abcd4f01843 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 19 Oct 2025 23:33:04 -0400 Subject: [PATCH 1/4] fix: expand variables for release tasks Procfile commands need to be expanded with actual environment variables as procfile-util will otherwise empty them out. This doesn't happen for app.json scripts as they are never expanded until the docker container gets created. Closes #8050 --- plugins/ps/functions.go | 25 +++++++++++++++++++++++-- plugins/ps/triggers.go | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/plugins/ps/functions.go b/plugins/ps/functions.go index b6af4f6dc..068f8ab9e 100644 --- a/plugins/ps/functions.go +++ b/plugins/ps/functions.go @@ -18,14 +18,35 @@ func canScaleApp(appName string) bool { return common.ToBool(canScale) } -func getProcfileCommand(procfilePath string, processType string, port int) (string, error) { +func getProcfileCommand(appName string, procfilePath string, processType string, port int) (string, error) { if !common.FileExists(procfilePath) { return "", errors.New("No procfile found") } + configResult, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "config-export", + Args: []string{appName, "false", "true", "envfile"}, + }) + if err != nil { + return "", err + } + + // write the envfile to a temporary file + tempFile, err := os.CreateTemp("", "envfile-*.env") + if err != nil { + return "", err + } + defer os.Remove(tempFile.Name()) + if _, err := tempFile.Write(configResult.StdoutBytes()); err != nil { + return "", err + } + if err := tempFile.Close(); err != nil { + return "", err + } + result, err := common.CallExecCommand(common.ExecCommandInput{ Command: "procfile-util", - Args: []string{"show", "--procfile", procfilePath, "--process-type", processType, "--default-port", strconv.Itoa(port)}, + Args: []string{"show", "--procfile", procfilePath, "--process-type", processType, "--default-port", strconv.Itoa(port), "--env-file", tempFile.Name()}, }) if err != nil { return "", fmt.Errorf("Error running procfile-util: %s", err) diff --git a/plugins/ps/triggers.go b/plugins/ps/triggers.go index ad69a9f61..0e355933c 100644 --- a/plugins/ps/triggers.go +++ b/plugins/ps/triggers.go @@ -274,7 +274,7 @@ func TriggerProcfileGetCommand(appName string, processType string, port int) err return nil } - command, err := getProcfileCommand(getProcessSpecificProcfilePath(appName), processType, port) + command, err := getProcfileCommand(appName, getProcessSpecificProcfilePath(appName), processType, port) if err != nil { return err } From c7c22d83924f66d4f0a7e6a2b195dcf19a74662a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 25 Oct 2025 07:25:54 -0400 Subject: [PATCH 2/4] fix: use plugin:trigger command to test the procfile-get-command trigger --- tests/unit/ps-general-1.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/ps-general-1.bats b/tests/unit/ps-general-1.bats index 38bf03193..05aff2709 100644 --- a/tests/unit/ps-general-1.bats +++ b/tests/unit/ps-general-1.bats @@ -99,12 +99,12 @@ teardown() { web: node web.js --port \$PORT worker: node worker.js EOF - PLUGIN_PATH=/var/lib/dokku/plugins PLUGIN_CORE_AVAILABLE_PATH=/var/lib/dokku/core-plugins/available DOKKU_LIB_ROOT=/var/lib/dokku run plugn trigger procfile-get-command "$TEST_APP" web 5001 + run /bin/bash -c "dokku plugin:trigger procfile-get-command '$TEST_APP' web 5001" echo "output: $output" echo "status: $status" assert_output "node web.js --port 5001" - PLUGIN_PATH=/var/lib/dokku/plugins PLUGIN_CORE_AVAILABLE_PATH=/var/lib/dokku/core-plugins/available DOKKU_LIB_ROOT=/var/lib/dokku run plugn trigger procfile-get-command "$TEST_APP" worker + run /bin/bash -c "dokku plugin:trigger procfile-get-command '$TEST_APP' worker" echo "output: $output" echo "status: $status" assert_output "node worker.js" From 66eff6f15e126eb2fe46463bf1717e65abfa7429 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 25 Oct 2025 07:29:12 -0400 Subject: [PATCH 3/4] test: add test for release command --- tests/unit/ps-general-1.bats | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/unit/ps-general-1.bats b/tests/unit/ps-general-1.bats index 05aff2709..661d56395 100644 --- a/tests/unit/ps-general-1.bats +++ b/tests/unit/ps-general-1.bats @@ -98,7 +98,14 @@ teardown() { cat <"$DOKKU_LIB_ROOT/data/ps/$TEST_APP/Procfile" web: node web.js --port \$PORT worker: node worker.js +release: interpolated $ENV_VAR EOF + + run /bin/bash -c "dokku config:set '$TEST_APP' ENV_VAR=value" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku plugin:trigger procfile-get-command '$TEST_APP' web 5001" echo "output: $output" echo "status: $status" @@ -108,6 +115,11 @@ EOF echo "output: $output" echo "status: $status" assert_output "node worker.js" + + run /bin/bash -c "dokku plugin:trigger procfile-get-command '$TEST_APP' release 5001" + echo "output: $output" + echo "status: $status" + assert_output "interpolated value" } @test "(ps:scale) update formations from Procfile" { From cb4ac3353e9a731119d3b065fe0ba2e70626bd1e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 26 Oct 2025 23:45:08 -0400 Subject: [PATCH 4/4] fix: escape the dollar-sign so it gets properly set in the Procfile --- tests/unit/ps-general-1.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/ps-general-1.bats b/tests/unit/ps-general-1.bats index 661d56395..a6fb02da1 100644 --- a/tests/unit/ps-general-1.bats +++ b/tests/unit/ps-general-1.bats @@ -98,7 +98,7 @@ teardown() { cat <"$DOKKU_LIB_ROOT/data/ps/$TEST_APP/Procfile" web: node web.js --port \$PORT worker: node worker.js -release: interpolated $ENV_VAR +release: interpolated \$ENV_VAR EOF run /bin/bash -c "dokku config:set '$TEST_APP' ENV_VAR=value"