@@ -187,13 +187,6 @@ func (o *projectOptions) toProject(services []string, po ...cli.ProjectOptionsFn
187
187
return nil , compose .WrapComposeError (err )
188
188
}
189
189
190
- ef := o .EnvFile
191
- if ef != "" && ! filepath .IsAbs (ef ) {
192
- ef , err = filepath .Abs (ef )
193
- if err != nil {
194
- return nil , err
195
- }
196
- }
197
190
for i , s := range project .Services {
198
191
s .CustomLabels = map [string ]string {
199
192
api .ProjectLabel : project .Name ,
@@ -203,8 +196,8 @@ func (o *projectOptions) toProject(services []string, po ...cli.ProjectOptionsFn
203
196
api .ConfigFilesLabel : strings .Join (project .ComposeFiles , "," ),
204
197
api .OneoffLabel : "False" , // default, will be overridden by `run` command
205
198
}
206
- if ef != "" {
207
- s .CustomLabels [api .EnvironmentFileLabel ] = ef
199
+ if o . EnvFile != "" {
200
+ s .CustomLabels [api .EnvironmentFileLabel ] = o . EnvFile
208
201
}
209
202
project .Services [i ] = s
210
203
}
@@ -250,7 +243,7 @@ func RunningAsStandalone() bool {
250
243
}
251
244
252
245
// RootCommand returns the compose command with its child commands
253
- func RootCommand (dockerCli command.Cli , backend api.Service ) * cobra.Command {
246
+ func RootCommand (dockerCli command.Cli , backend api.Service ) * cobra.Command { //nolint:gocyclo
254
247
// filter out useless commandConn.CloseWrite warning message that can occur
255
248
// when using a remote context that is unreachable: "commandConn.CloseWrite: commandconn: failed to wait: signal: killed"
256
249
// https://github.com/docker/cli/blob/e1f24d3c93df6752d3c27c8d61d18260f141310c/cli/connhelper/commandconn/commandconn.go#L203-L215
@@ -326,6 +319,12 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command {
326
319
opts .ProjectDir = opts .WorkDir
327
320
fmt .Fprint (os .Stderr , aec .Apply ("option '--workdir' is DEPRECATED at root level! Please use '--project-directory' instead.\n " , aec .RedF ))
328
321
}
322
+ if opts .EnvFile != "" && ! filepath .IsAbs (opts .EnvFile ) {
323
+ opts .EnvFile , err = filepath .Abs (opts .EnvFile )
324
+ if err != nil {
325
+ return err
326
+ }
327
+ }
329
328
if parallel > 0 {
330
329
backend .MaxConcurrency (parallel )
331
330
}
0 commit comments