Skip to content

Commit

Permalink
support --compose-file - as stdin
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Mariani <marco.mariani@alterway.fr>
  • Loading branch information
mmariani committed Jul 18, 2017
1 parent e3746d3 commit 708edf5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cli/command/stack/deploy_composefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"sort"
"strings"

Expand Down Expand Up @@ -121,11 +122,20 @@ func propertyWarnings(properties map[string]string) string {
func getConfigDetails(composefile string) (composetypes.ConfigDetails, error) {
var details composetypes.ConfigDetails

absPath, err := filepath.Abs(composefile)
if err != nil {
return details, err
if composefile == "-" && runtime.GOOS != "windows" {
composefile = "/dev/stdin"
workingDir, err := os.Getwd()
if err != nil {
return details, err
}
details.WorkingDir = workingDir
} else {
absPath, err := filepath.Abs(composefile)
if err != nil {
return details, err
}
details.WorkingDir = filepath.Dir(absPath)
}
details.WorkingDir = filepath.Dir(absPath)

configFile, err := getConfigFile(composefile)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/commandline/stack_deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Creating service vossibility_ghollector
Creating service vossibility_lookupd
```

The Compose file can also be provided as standard input with `--compose-file -`.

Only a single Compose file is accepted. If your configuration is split between
multiple Compose files, e.g. a base configuration and environment-specific overrides,
you can combine these by passing them to `docker-compose config` with the `-f` option
Expand Down

0 comments on commit 708edf5

Please sign in to comment.