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.
This commit is contained in:
Jose Diaz-Gonzalez
2026-04-25 03:59:15 -04:00
parent 17c549ee63
commit c3db713c27

View File

@@ -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)
}