diff --git a/cli/build.go b/cli/build.go index 5dd6f77fa..c14fb09f0 100644 --- a/cli/build.go +++ b/cli/build.go @@ -43,17 +43,17 @@ func NewBuildCommand() cli.Command { }, cli.StringFlag{ Name: "docker-host", - Value: "", + Value: getHost(), Usage: "docker daemon address", }, cli.StringFlag{ Name: "docker-cert", - Value: "", + Value: getCert(), Usage: "docker daemon tls certificate", }, cli.StringFlag{ Name: "docker-key", - Value: "", + Value: getKey(), Usage: "docker daemon tls key", }, }, @@ -204,3 +204,23 @@ func run(path, identity, dockerhost, dockercert, dockerkey string, publish, depl return builder.BuildState.ExitCode, nil } + +func getHost() string { + return os.Getenv("DOCKER_HOST") +} + +func getCert() string { + if os.Getenv("DOCKER_CERT_PATH") != "" && os.Getenv("DOCKER_TLS_VERIFY") == "1" { + return filepath.Join(os.Getenv("DOCKER_CERT_PATH"), "cert.pem") + } else { + return "" + } +} + +func getKey() string { + if os.Getenv("DOCKER_CERT_PATH") != "" && os.Getenv("DOCKER_TLS_VERIFY") == "1" { + return filepath.Join(os.Getenv("DOCKER_CERT_PATH"), "key.pem") + } else { + return "" + } +}