From c3db713c273cc6cb771eca28e7303c415692ee3c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 25 Apr 2026 03:59:15 -0400 Subject: [PATCH] fix: ensure app ENV directory exists at DOKKU_LIB_ROOT/config/{app} The post-create trigger only created the property directory at DOKKU_LIB_ROOT/config/config/{app}/, but getAppFile() writes the ENV file to DOKKU_LIB_ROOT/config/{app}/ENV. Add setupAppConfigDir to create and permission the ENV directory in both post-create and install triggers, and clean it up on post-delete. --- plugins/config/triggers.go | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/plugins/config/triggers.go b/plugins/config/triggers.go index d82a0d987..02edcb160 100644 --- a/plugins/config/triggers.go +++ b/plugins/config/triggers.go @@ -60,6 +60,23 @@ func TriggerConfigUnset(appName string, key string, restart bool) error { return nil } +func setupAppConfigDir(appName string) error { + appFile, err := getAppFile(appName) + if err != nil { + return err + } + + appConfigDir := filepath.Dir(appFile) + if err := os.MkdirAll(appConfigDir, 0755); err != nil { + return err + } + + return common.SetPermissions(common.SetPermissionInput{ + Filename: appConfigDir, + Mode: os.FileMode(0755), + }) +} + func migrateGlobalEnv() error { if err := common.PropertySetup("--global"); err != nil { return fmt.Errorf("Unable to setup global environment: %s", err.Error()) @@ -114,6 +131,10 @@ func TriggerInstall() error { return fmt.Errorf("Unable to setup app environment: %s", err.Error()) } + if err := setupAppConfigDir(appName); err != nil { + return fmt.Errorf("Unable to setup app config directory: %s", err.Error()) + } + oldEnvFile := filepath.Join(common.AppRoot(appName), "ENV") isMigrated := common.PropertyGetDefault("config", appName, "env-migrated", "") // delete the old file on the next install @@ -198,10 +219,19 @@ func TriggerPostAppRenameSetup(oldAppName string, newAppName string) error { // TriggerPostCreate ensures apps have the correct config structure func TriggerPostCreate(appName string) error { - return common.PropertySetupApp("config", appName) + if err := common.PropertySetupApp("config", appName); err != nil { + return err + } + + return setupAppConfigDir(appName) } // TriggerPostDelete destroys the config data for a given app container func TriggerPostDelete(appName string) error { + appFile, err := getAppFile(appName) + if err == nil { + os.RemoveAll(filepath.Dir(appFile)) + } + return common.PropertyDestroy("config", appName) }