@@ -150,24 +150,34 @@ func ExportEnv(config config.Config) string {
150150 return strings .Join (builder , "\n " )
151151}
152152
153+ //TODO: main docker-compose should include secondary docker-compose files inside it somehow.
153154type DockerComposeCmd struct {
154155 OutputDir string `name:"output dir" default:"./compose" short:"o" help:"Output dir for docker compose files." predictor:"dir"`
155156 BakeEnv bool `short:"e" help:"Bake in the configured environment to image after build."`
156157
157- Config string `arg:"" name:"config" help:"config" predictor:"config"`
158+ Config [] string `arg:"" name:"config" help:"config to include in the docker-compose. The first config is assuemd to be the main container, and will be the parent folder of the ouput project " predictor:"config"`
158159}
159160
160161func (r * DockerComposeCmd ) Run (cli * Cli , ctx * context.Context ) error {
161- config , err := config .LoadConfig (cli .ConfDir , r .Config , true , cli .TemplatesDir )
162- if err != nil {
163- return errors .New ("YAML syntax error. Please check your containers/*.yml config files." )
162+ if len (r .Config ) < 1 {
163+ return errors .New ("No config given, need at least one container name." )
164164 }
165- dir := r .OutputDir + "/" + r .Config
165+
166+ dir := r .OutputDir + "/" + r .Config [0 ]
166167 if err := os .MkdirAll (dir , 0755 ); err != nil && ! os .IsExist (err ) {
167168 return err
168169 }
169- if err := WriteDockerCompose (* config , dir , r .BakeEnv ); err != nil {
170- return err
170+
171+ configs := []* config.Config {}
172+ for _ , configName := range (r .Config ) {
173+ config , err := config .LoadConfig (cli .ConfDir , configName , true , cli .TemplatesDir )
174+ if err != nil {
175+ return errors .New ("YAML syntax error. Please check your containers/*.yml config files." )
176+ }
177+ if err := WriteDockerCompose (* config , dir , r .BakeEnv ); err != nil {
178+ return err
179+ }
180+ configs = append (configs , config )
171181 }
172182 return nil
173183}
0 commit comments