diff --git a/images/orderer/Dockerfile.in b/images/orderer/Dockerfile.in index 68fd5d2061a..3888300683d 100644 --- a/images/orderer/Dockerfile.in +++ b/images/orderer/Dockerfile.in @@ -1,7 +1,7 @@ FROM hyperledger/fabric-baseimage:_BASE_TAG_ +ENV ORDERER_CFG_PATH /etc/hyperledger/fabric RUN mkdir -p /var/hyperledger/db /etc/hyperledger/fabric COPY payload/orderer /usr/local/bin -COPY payload/orderer.yaml /etc/hyperledger/fabric -WORKDIR /etc/hyperledger/fabric +COPY payload/orderer.yaml $ORDERER_CFG_PATH EXPOSE 7050 CMD orderer diff --git a/orderer/config/config.go b/orderer/config/config.go index dbf40dc1642..251029bc10f 100644 --- a/orderer/config/config.go +++ b/orderer/config/config.go @@ -192,25 +192,30 @@ func (c *TopLevel) completeInitialization() { func Load() *TopLevel { config := viper.New() + config.SetConfigName("orderer") + alternativeCfgPath := os.Getenv("ORDERER_CFG_PATH") + if alternativeCfgPath != "" { + logger.Infof("User defined config file path: %s", alternativeCfgPath) + config.AddConfigPath(alternativeCfgPath) // Path to look for the config file in + } else { + config.AddConfigPath("./") + config.AddConfigPath("../../.") + config.AddConfigPath("../orderer/") + config.AddConfigPath("../../orderer/") + // Path to look for the config file in based on GOPATH + gopath := os.Getenv("GOPATH") + for _, p := range filepath.SplitList(gopath) { + ordererPath := filepath.Join(p, "src/github.com/hyperledger/fabric/orderer/") + config.AddConfigPath(ordererPath) + } + } + // for environment variables config.SetEnvPrefix(Prefix) config.AutomaticEnv() replacer := strings.NewReplacer(".", "_") config.SetEnvKeyReplacer(replacer) - config.SetConfigName("orderer") - config.AddConfigPath("./") - config.AddConfigPath("../../.") - config.AddConfigPath("../orderer/") - config.AddConfigPath("../../orderer/") - config.AddConfigPath("/etc/hyperledger/fabric/") - // Path to look for the config file in based on GOPATH - gopath := os.Getenv("GOPATH") - for _, p := range filepath.SplitList(gopath) { - ordererPath := filepath.Join(p, "src/github.com/hyperledger/fabric/orderer/") - config.AddConfigPath(ordererPath) - } - err := config.ReadInConfig() if err != nil { panic(fmt.Errorf("Error reading %s plugin config: %s", Prefix, err))