backend: Add realtime output on building phase

The realtime output could be configured through
LUET_GENERAL__SHOW_BUILD_OUTPUT environment
variable or related config option or through
`--live-output` option.
This commit is contained in:
Daniele Rondina
2021-02-01 19:10:16 +01:00
parent 2854c68209
commit c1fe3278fa
5 changed files with 108 additions and 14 deletions

View File

@@ -56,10 +56,11 @@ func (*SimpleDocker) BuildImage(opts compiler.CompilerBackendOptions) error {
Info(":whale2: Building image " + name)
cmd := exec.Command("docker", buildarg...)
cmd.Dir = path
out, err := cmd.CombinedOutput()
_, err := runCommand(cmd)
if err != nil {
return errors.Wrap(err, "Failed building image: "+string(out))
return err
}
Info(":whale: Building image " + name + " done")
if os.Getenv("DOCKER_SQUASH") == "true" {
@@ -77,12 +78,6 @@ func (*SimpleDocker) BuildImage(opts compiler.CompilerBackendOptions) error {
Info(":whale: Squashing image " + name + " done")
}
if config.LuetCfg.GetGeneral().ShowBuildOutput {
Info(string(out))
} else {
Debug(string(out))
}
return nil
}