@@ -59,14 +59,14 @@ func DockerComposeService(config config.Config) ComposeService {
5959	}
6060	slices .Sort (volumes )
6161	ports  :=  []string {}
62- 	for  _ , v  :=  range  config .Expose  {
63- 		ports  =  append (ports , v )
64- 	}
62+ 	ports  =  append (ports , config .Expose ... )
6563	slices .Sort (ports )
6664
6765	args  :=  []string {}
68- 	for  k , _  :=  range  config .Env  {
69- 		args  =  append (args , k )
66+ 	for  k  :=  range  config .Env  {
67+ 		if  ! slices .Contains (utils .KnownSecrets , k ) {
68+ 			args  =  append (args , k )
69+ 		}
7070	}
7171	slices .Sort (args )
7272
@@ -86,7 +86,7 @@ func DockerComposeService(config config.Config) ComposeService {
8686	}
8787}
8888
89- func  WriteDockerCompose (configs  []config.Config , dir  string ,  bakeEnv   bool ) error  {
89+ func  WriteDockerCompose (configs  []config.Config , dir  string ) error  {
9090	if  err  :=  WriteEnvConfig (configs , dir ); err  !=  nil  {
9191		return  err 
9292	}
@@ -95,14 +95,18 @@ func WriteDockerCompose(configs []config.Config, dir string, bakeEnv bool) error
9595	composeServices  :=  map [string ]ComposeService {}
9696	composeVolumes  :=  map [string ]* interface {}{}
9797	for  _ , config  :=  range  configs  {
98- 		if  err  :=  WriteDockerfile (config , dir , pupsArgs ,  bakeEnv ); err  !=  nil  {
98+ 		if  err  :=  WriteDockerfile (config , dir , pupsArgs ); err  !=  nil  {
9999			return  err 
100100		}
101101		composeServices [config .Name ] =  DockerComposeService (config )
102102
103+ 		regex , err  :=  regexp .Compile (`^[A-Za-z]` )
104+ 		if  err  !=  nil  {
105+ 			return  err 
106+ 		}
103107		for  _ , v  :=  range  config .Volumes  {
104108			// if this is a docker volume (vs a bind mount), add to global volume list 
105- 			matched ,  _   :=  regexp .MatchString (`^[A-Za-z]` ,  v .Volume .Host )
109+ 			matched   :=  regex .MatchString (v .Volume .Host )
106110			if  matched  {
107111				composeVolumes [v .Volume .Host ] =  nil 
108112			}
@@ -128,13 +132,13 @@ func WriteDockerCompose(configs []config.Config, dir string, bakeEnv bool) error
128132	return  nil 
129133}
130134
131- func  WriteDockerfile (config  config.Config , dir  string , pupsArgs  string ,  bakeEnv   bool ) error  {
132- 	if  err  :=  config .WriteYamlConfig (dir ); err  !=  nil  {
135+ func  WriteDockerfile (config  config.Config , dir  string , pupsArgs  string ) error  {
136+ 	if  err  :=  config .WriteYamlConfig (dir ,  config . Name + ".yaml" ); err  !=  nil  {
133137		return  err 
134138	}
135139
136140	file  :=  strings .TrimRight (dir , "/" ) +  "/"  +  config .Name  +  ".dockerfile" 
137- 	if  err  :=  os .WriteFile (file , []byte (config .Dockerfile (pupsArgs , bakeEnv )), 0660 ); err  !=  nil  {
141+ 	if  err  :=  os .WriteFile (file , []byte (config .Dockerfile (pupsArgs , config . Name + ".yaml" )), 0660 ); err  !=  nil  {
138142		return  errors .New ("error writing dockerfile Dockerfile "  +  file )
139143	}
140144	return  nil 
@@ -143,7 +147,7 @@ func WriteDockerfile(config config.Config, dir string, pupsArgs string, bakeEnv
143147func  WriteEnvConfig (configs  []config.Config , dir  string ) error  {
144148	file  :=  strings .TrimRight (dir , "/" ) +  "/.envrc" 
145149	if  err  :=  os .WriteFile (file , []byte (ExportEnv (configs )), 0660 ); err  !=  nil  {
146- 		return  errors . New ( "error writing export env "   +   file ) 
150+ 		return  err 
147151	}
148152	return  nil 
149153}
@@ -167,15 +171,13 @@ func ExportEnv(configs []config.Config) string {
167171}
168172
169173type  DockerComposeCmd  struct  {
170- 	OutputDir  string  `name:"output dir" default:"./compose" short:"o" help:"Output dir for docker compose files." predictor:"dir"` 
171- 	BakeEnv    bool    `short:"e" help:"Bake in the configured environment to image after build."` 
172- 
173- 	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"` 
174+ 	OutputDir  string    `name:"output dir" default:"./compose" short:"o" help:"Output dir for docker compose files." predictor:"dir"` 
175+ 	Config     []string  `arg:"" name:"config" help:"config to include in the docker-compose. The first config is assumed to be the main container, and will be the parent folder of the ouput project" predictor:"config"` 
174176}
175177
176178func  (r  * DockerComposeCmd ) Run (cli  * Cli , ctx  * context.Context ) error  {
177179	if  len (r .Config ) <  1  {
178- 		return  errors .New ("No  config given, need at least one container name. " )
180+ 		return  errors .New ("empty  config array " )
179181	}
180182
181183	dir  :=  r .OutputDir  +  "/"  +  r .Config [0 ]
@@ -187,11 +189,11 @@ func (r *DockerComposeCmd) Run(cli *Cli, ctx *context.Context) error {
187189	for  _ , configName  :=  range  r .Config  {
188190		config , err  :=  config .LoadConfig (cli .ConfDir , configName , true , cli .TemplatesDir )
189191		if  err  !=  nil  {
190- 			return  errors . New ( "YAML syntax error. Please check your containers/*.yml config files." ) 
192+ 			return  err 
191193		}
192194		configs  =  append (configs , * config )
193195	}
194- 	if  err  :=  WriteDockerCompose (configs , dir ,  r . BakeEnv ); err  !=  nil  {
196+ 	if  err  :=  WriteDockerCompose (configs , dir ); err  !=  nil  {
195197		return  err 
196198	}
197199	return  nil 
0 commit comments