Skip to content

Commit 42bfa7b

Browse files
committed
build: follow up fixes for build stream
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
1 parent 30933b5 commit 42bfa7b

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

cli/command/image/build.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,16 @@ func (out *lastProgressOutput) WriteProgress(prog progress.Progress) error {
165165
// nolint: gocyclo
166166
func runBuild(dockerCli command.Cli, options buildOptions) error {
167167
var (
168-
buildCtx io.ReadCloser
169-
dockerfileCtx io.ReadCloser
170-
err error
171-
contextDir string
172-
tempDir string
173-
relDockerfile string
174-
progBuff io.Writer
175-
buildBuff io.Writer
176-
remote string
168+
buildCtx io.ReadCloser
169+
dockerfileCtx io.ReadCloser
170+
err error
171+
contextDir string
172+
tempDir string
173+
relDockerfile string
174+
progBuff io.Writer
175+
buildBuff io.Writer
176+
remote string
177+
quietOutputBuffer *bytes.Buffer
177178
)
178179

179180
if options.dockerfileFromStdin() {
@@ -188,7 +189,8 @@ func runBuild(dockerCli command.Cli, options buildOptions) error {
188189
buildBuff = dockerCli.Out()
189190
if options.quiet {
190191
progBuff = bytes.NewBuffer(nil)
191-
buildBuff = bytes.NewBuffer(nil)
192+
quietOutputBuffer = bytes.NewBuffer(nil)
193+
buildBuff = quietOutputBuffer
192194
}
193195
if options.imageIDFile != "" {
194196
// Avoid leaving a stale file if we eventually fail
@@ -282,7 +284,8 @@ func runBuild(dockerCli command.Cli, options buildOptions) error {
282284
buildCtx = replaceDockerfileTarWrapper(ctx, buildCtx, relDockerfile, translator, &resolvedTags)
283285
} else if dockerfileCtx != nil {
284286
// if there was not archive context still do the possible replacements in Dockerfile
285-
newDockerfile, _, err := rewriteDockerfileFrom(ctx, dockerfileCtx, translator)
287+
var newDockerfile []byte
288+
newDockerfile, resolvedTags, err = rewriteDockerfileFrom(ctx, dockerfileCtx, translator)
286289
if err != nil {
287290
return err
288291
}
@@ -433,7 +436,7 @@ func runBuild(dockerCli command.Cli, options buildOptions) error {
433436
// Everything worked so if -q was provided the output from the daemon
434437
// should be just the image ID and we'll print that to stdout.
435438
if options.quiet {
436-
imageID = fmt.Sprintf("%s", buildBuff)
439+
imageID = quietOutputBuffer.String()
437440
fmt.Fprintf(dockerCli.Out(), imageID)
438441
}
439442

0 commit comments

Comments
 (0)