Skip to content

Commit

Permalink
Fix stdin error on windows by using Dockerfile instead
Browse files Browse the repository at this point in the history
JIRA CLOUDINFRA-311
  • Loading branch information
Julien Duchesne committed Nov 29, 2017
1 parent 37350a6 commit 443aa22
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"os/user"
Expand Down Expand Up @@ -125,23 +125,26 @@ func getImage() string {
return config.GetImageName()
}

args := []string{"build", "-", "--quiet", "--force-rm"}
var dockerFile string
dockerFile += fmt.Sprintln("FROM", config.GetImageName())
dockerFile += fmt.Sprintln(config.ImageBuild)

tempDir, _ := ioutil.TempDir(".", "tgf-docker")
ioutil.WriteFile(fmt.Sprintf("%s/Dockerfile", tempDir), []byte(dockerFile), 0644)
defer os.RemoveAll(tempDir)

args := []string{"build", tempDir, "--quiet", "--force-rm"}
if refresh {
args = append(args, "--pull")
}
buildCmd := exec.Command("docker", args...)
var dockerFile string
dockerFile += fmt.Sprintln("FROM", config.GetImageName())
dockerFile += fmt.Sprintln(config.ImageBuild)

if debug {
printfDebug(os.Stderr, "%s\n", strings.Join(buildCmd.Args, " "))
printfDebug(os.Stderr, "%s", dockerFile)
}
buildCmd.Stderr = os.Stderr
stdin := Must(buildCmd.StdinPipe()).(io.WriteCloser)
fmt.Fprintln(stdin, dockerFile)
stdin.Close()

return strings.TrimSpace(string(Must(buildCmd.Output()).([]byte)))
}

Expand Down

0 comments on commit 443aa22

Please sign in to comment.