1
0

Add stdout trace for container build

This commit is contained in:
dump_stack() 2023-04-06 18:12:56 +00:00
parent f75c70db94
commit 7dddf71d93
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -57,10 +57,32 @@ func (c container) Build(imagePath string) (output string, err error) {
args = append(args, "-t", c.name, imagePath) args = append(args, "-t", c.name, imagePath)
cmd := exec.Command("docker", args...) cmd := exec.Command("docker", args...)
log.Debug().Msgf("%v", cmd)
rawOutput, err := cmd.CombinedOutput() flog := log.With().
output = string(rawOutput) Str("command", fmt.Sprintf("%v", cmd)).
Logger()
stdout, err := cmd.StdoutPipe()
if err != nil {
return
}
cmd.Stderr = cmd.Stdout
err = cmd.Start()
if err != nil {
return
}
go func() {
scanner := bufio.NewScanner(stdout)
for scanner.Scan() {
m := scanner.Text()
output += m + "\n"
flog.Trace().Str("stdout", m).Msg("")
}
}()
err = cmd.Wait()
return return
} }