fix: reference app-specific config.json for retrieving registry auths

This commit is contained in:
Jose Diaz-Gonzalez
2026-01-10 02:33:59 -05:00
parent b9ede65d6e
commit 9bb766cf17
3 changed files with 13 additions and 1 deletions

View File

@@ -25,6 +25,14 @@ func GetAppRegistryConfigPath(appName string) string {
return filepath.Join(GetAppRegistryConfigDir(appName), "config.json") return filepath.Join(GetAppRegistryConfigDir(appName), "config.json")
} }
func GetComputedAppRegistryConfigDir(appName string) string {
if HasAppRegistryAuth(appName) {
return GetAppRegistryConfigDir(appName)
}
return filepath.Join(os.Getenv("DOKKU_ROOT"), ".docker")
}
// HasAppRegistryAuth checks if an app has registry credentials configured // HasAppRegistryAuth checks if an app has registry credentials configured
func HasAppRegistryAuth(appName string) bool { func HasAppRegistryAuth(appName string) bool {
configPath := GetAppRegistryConfigPath(appName) configPath := GetAppRegistryConfigPath(appName)

View File

@@ -12,6 +12,7 @@ require (
github.com/dokku/dokku/plugins/docker-options v0.0.0-20250618161309-8d0c35f1333c github.com/dokku/dokku/plugins/docker-options v0.0.0-20250618161309-8d0c35f1333c
github.com/dokku/dokku/plugins/logs v0.0.0-20250618161309-8d0c35f1333c github.com/dokku/dokku/plugins/logs v0.0.0-20250618161309-8d0c35f1333c
github.com/dokku/dokku/plugins/nginx-vhosts v0.0.0-20250618161309-8d0c35f1333c github.com/dokku/dokku/plugins/nginx-vhosts v0.0.0-20250618161309-8d0c35f1333c
github.com/dokku/dokku/plugins/registry v0.0.0-20250618161309-8d0c35f1333c
github.com/fatih/color v1.18.0 github.com/fatih/color v1.18.0
github.com/fluxcd/pkg/kustomize v1.24.0 github.com/fluxcd/pkg/kustomize v1.24.0
github.com/go-openapi/jsonpointer v0.22.4 github.com/go-openapi/jsonpointer v0.22.4
@@ -190,6 +191,8 @@ replace github.com/dokku/dokku/plugins/logs => ../logs
replace github.com/dokku/dokku/plugins/nginx-vhosts => ../nginx-vhosts replace github.com/dokku/dokku/plugins/nginx-vhosts => ../nginx-vhosts
replace github.com/dokku/dokku/plugins/registry => ../registry
replace github.com/joho/godotenv => github.com/joho/godotenv v1.2.0 replace github.com/joho/godotenv => github.com/joho/godotenv v1.2.0
replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16 replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16

View File

@@ -23,6 +23,7 @@ import (
"github.com/dokku/dokku/plugins/config" "github.com/dokku/dokku/plugins/config"
"github.com/dokku/dokku/plugins/cron" "github.com/dokku/dokku/plugins/cron"
nginxvhosts "github.com/dokku/dokku/plugins/nginx-vhosts" nginxvhosts "github.com/dokku/dokku/plugins/nginx-vhosts"
"github.com/dokku/dokku/plugins/registry"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/gosimple/slug" "github.com/gosimple/slug"
"github.com/kballard/go-shellquote" "github.com/kballard/go-shellquote"
@@ -405,7 +406,7 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
pullSecretBase64 := base64.StdEncoding.EncodeToString([]byte("")) pullSecretBase64 := base64.StdEncoding.EncodeToString([]byte(""))
imagePullSecrets := getComputedImagePullSecrets(appName) imagePullSecrets := getComputedImagePullSecrets(appName)
if imagePullSecrets == "" { if imagePullSecrets == "" {
dockerConfigPath := filepath.Join(os.Getenv("DOKKU_ROOT"), ".docker/config.json") dockerConfigPath := filepath.Join(registry.GetComputedAppRegistryConfigDir(appName), "config.json")
if fi, err := os.Stat(dockerConfigPath); err == nil && !fi.IsDir() { if fi, err := os.Stat(dockerConfigPath); err == nil && !fi.IsDir() {
b, err := os.ReadFile(dockerConfigPath) b, err := os.ReadFile(dockerConfigPath)
if err != nil { if err != nil {