@@ -19,6 +19,10 @@ import (
1919 "gopkg.in/yaml.v2"
2020)
2121
22+ type appConfig struct {
23+ Host string `yaml:"host"`
24+ }
25+
2226type configSettings struct {
2327 Name string `yaml:"name"`
2428 File string `yaml:"file"`
@@ -132,6 +136,41 @@ func loadEnvFromConfigFile(filename string, stdin io.Reader) ([]string, error) {
132136 return environmentFromYaml (yamlFile )
133137}
134138
139+ func loadAppConfig (filename string ) (* appConfig , error ) {
140+ cfg := & appConfig {}
141+ targetPath , err := os .Getwd ()
142+ if err != nil {
143+ return nil , err
144+ }
145+
146+ rootDir := filepath .Join (filepath .VolumeName (targetPath ), "/" )
147+
148+ for {
149+ configPath := filepath .Join (targetPath , filename )
150+ data , err := ioutil .ReadFile (configPath )
151+ if err != nil {
152+ if os .IsNotExist (err ) {
153+ if targetPath == rootDir {
154+ return cfg , nil
155+ }
156+ targetPath = filepath .Dir (targetPath )
157+ continue
158+ }
159+ break
160+ }
161+
162+ log .Printf ("Reading config file: %s" , configPath )
163+ err = yaml .Unmarshal (data , cfg )
164+ if err != nil {
165+ break
166+ }
167+
168+ return cfg , nil
169+ }
170+
171+ return nil , err
172+ }
173+
135174var auth = flag .BoolP ("with-registry-auth" , "a" , false , "Send registry authentication details to Swarm agents" )
136175var prune = flag .BoolP ("prune" , "p" , false , "Prune services that are no longer referenced" )
137176var host = flag .StringP ("host" , "H" , "" , "Daemon socket(s) to connect to" )
@@ -148,6 +187,11 @@ func main() {
148187 log .Fatal (err )
149188 }
150189
190+ cfg , err := loadAppConfig (".docker-deploy.yml" )
191+ if err != nil {
192+ log .Fatal (err )
193+ }
194+
151195 var buf bytes.Buffer
152196 tee := io .TeeReader (os .Stdin , & buf )
153197 env , err := loadEnvFromConfigFiles (* composeFiles , tee )
@@ -162,6 +206,8 @@ func main() {
162206
163207 if * host != "" {
164208 args = append ([]string {"--host" , * host }, args ... )
209+ } else if cfg .Host != "" {
210+ args = append ([]string {"--host" , cfg .Host }, args ... )
165211 }
166212
167213 if * auth {
0 commit comments