diff --git a/make/common/templates/ui/env b/make/common/templates/ui/env index 5dee4ba9ed..ad1a9fd699 100644 --- a/make/common/templates/ui/env +++ b/make/common/templates/ui/env @@ -6,3 +6,4 @@ GODEBUG=netdns=cgo ADMINSERVER_URL=$adminserver_url UAA_CA_ROOT=/etc/ui/certificates/uaa_ca.pem _REDIS_URL=$redis_url +SYNC_REGISTRY=false diff --git a/src/ui/main.go b/src/ui/main.go index 99720f9378..a0c46baaea 100644 --- a/src/ui/main.go +++ b/src/ui/main.go @@ -18,6 +18,7 @@ import ( "fmt" "os" "reflect" + "strconv" "github.com/vmware/harbor/src/common/utils" "github.com/vmware/harbor/src/common/utils/log" @@ -147,9 +148,22 @@ func main() { beego.InsertFilter("/api/*", beego.BeforeRouter, filter.MediaTypeFilter("application/json")) initRouters() - if err := api.SyncRegistry(config.GlobalProjectMgr); err != nil { - log.Error(err) + + syncRegistry := os.Getenv("SYNC_REGISTRY") + sync, err := strconv.ParseBool(syncRegistry) + if err != nil{ + log.Errorf("Failed to parse SYNC_REGISTRY: %v", err) + //if err set it default to false + sync = false; } + if sync{ + if err := api.SyncRegistry(config.GlobalProjectMgr); err != nil { + log.Error(err) + } + }else { + log.Infof("Because SYNC_REGISTRY set false , no need to sync registry \n") + } + log.Info("Init proxy") proxy.Init() //go proxy.StartProxy()