mirror of https://github.com/docker/compose.git
Add environment_files label
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
caec924532
commit
dc80f6b6e7
|
@ -25,4 +25,6 @@ const (
|
||||||
ServiceTag = "com.docker.compose.service"
|
ServiceTag = "com.docker.compose.service"
|
||||||
// VolumeTag allow to track resource related to a compose volume
|
// VolumeTag allow to track resource related to a compose volume
|
||||||
VolumeTag = "com.docker.compose.volume"
|
VolumeTag = "com.docker.compose.volume"
|
||||||
|
// EnvironmentFileLabel is set in containers with the option "--env-file" when set
|
||||||
|
EnvironmentFileLabel = "com.docker.compose.project.environment_file"
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/docker/compose-cli/api/client"
|
"github.com/docker/compose-cli/api/client"
|
||||||
"github.com/docker/compose-cli/api/compose"
|
"github.com/docker/compose-cli/api/compose"
|
||||||
|
@ -175,6 +176,23 @@ func setup(ctx context.Context, opts composeOptions, services []string) (*client
|
||||||
service.PullPolicy = types.PullPolicyBuild
|
service.PullPolicy = types.PullPolicyBuild
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if opts.EnvFile != "" {
|
||||||
|
var services types.Services
|
||||||
|
for _, s := range project.Services {
|
||||||
|
ef := opts.EnvFile
|
||||||
|
if ef != "" {
|
||||||
|
if !filepath.IsAbs(ef) {
|
||||||
|
ef = filepath.Join(project.WorkingDir, opts.EnvFile)
|
||||||
|
}
|
||||||
|
if s.Labels == nil {
|
||||||
|
s.Labels = make(map[string]string)
|
||||||
|
}
|
||||||
|
s.Labels[compose.EnvironmentFileLabel] = ef
|
||||||
|
services = append(services, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
project.Services = services
|
||||||
|
}
|
||||||
|
|
||||||
return c, project, nil
|
return c, project, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,9 @@ package compose
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/compose-cli/api/compose"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
|
||||||
|
"github.com/docker/compose-cli/api/compose"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
Loading…
Reference in New Issue