Merge pull request #24978 from yongtang/24912-build-with-progress
Add hint of progress to the output of `docker build` Upstream-commit: 282b0aff08030a2521adf7d64bdd333f0864b720 Component: engine
This commit is contained in:
@ -233,6 +233,7 @@ func (b *Builder) build(stdout io.Writer, stderr io.Writer, out io.Writer) (stri
|
||||
}
|
||||
|
||||
var shortImgID string
|
||||
total := len(b.dockerfile.Children)
|
||||
for i, n := range b.dockerfile.Children {
|
||||
select {
|
||||
case <-b.clientCtx.Done():
|
||||
@ -242,7 +243,7 @@ func (b *Builder) build(stdout io.Writer, stderr io.Writer, out io.Writer) (stri
|
||||
default:
|
||||
// Not cancelled yet, keep going...
|
||||
}
|
||||
if err := b.dispatch(i, n); err != nil {
|
||||
if err := b.dispatch(i, total, n); err != nil {
|
||||
if b.options.ForceRemove {
|
||||
b.clearTmp()
|
||||
}
|
||||
@ -320,8 +321,9 @@ func BuildFromConfig(config *container.Config, changes []string) (*container.Con
|
||||
b.Stderr = ioutil.Discard
|
||||
b.disableCommit = true
|
||||
|
||||
total := len(ast.Children)
|
||||
for i, n := range ast.Children {
|
||||
if err := b.dispatch(i, n); err != nil {
|
||||
if err := b.dispatch(i, total, n); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ func init() {
|
||||
// such as `RUN` in ONBUILD RUN foo. There is special case logic in here to
|
||||
// deal with that, at least until it becomes more of a general concern with new
|
||||
// features.
|
||||
func (b *Builder) dispatch(stepN int, ast *parser.Node) error {
|
||||
func (b *Builder) dispatch(stepN int, stepTotal int, ast *parser.Node) error {
|
||||
cmd := ast.Value
|
||||
upperCasedCmd := strings.ToUpper(cmd)
|
||||
|
||||
@ -107,7 +107,7 @@ func (b *Builder) dispatch(stepN int, ast *parser.Node) error {
|
||||
original := ast.Original
|
||||
flags := ast.Flags
|
||||
strList := []string{}
|
||||
msg := fmt.Sprintf("Step %d : %s", stepN+1, upperCasedCmd)
|
||||
msg := fmt.Sprintf("Step %d/%d : %s", stepN+1, stepTotal, upperCasedCmd)
|
||||
|
||||
if len(ast.Flags) > 0 {
|
||||
msg += " " + strings.Join(ast.Flags, " ")
|
||||
|
||||
@ -184,7 +184,7 @@ func executeTestCase(t *testing.T, testCase dispatchTestCase) {
|
||||
|
||||
b := &Builder{runConfig: config, options: options, Stdout: ioutil.Discard, context: context}
|
||||
|
||||
err = b.dispatch(0, n.Children[0])
|
||||
err = b.dispatch(0, len(n.Children), n.Children[0])
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("No error when executing test %s", testCase.name)
|
||||
|
||||
@ -434,6 +434,7 @@ func (b *Builder) processImageFrom(img builder.Image) error {
|
||||
return err
|
||||
}
|
||||
|
||||
total := len(ast.Children)
|
||||
for i, n := range ast.Children {
|
||||
switch strings.ToUpper(n.Value) {
|
||||
case "ONBUILD":
|
||||
@ -442,7 +443,7 @@ func (b *Builder) processImageFrom(img builder.Image) error {
|
||||
return fmt.Errorf("%s isn't allowed as an ONBUILD trigger", n.Value)
|
||||
}
|
||||
|
||||
if err := b.dispatch(i, n); err != nil {
|
||||
if err := b.dispatch(i, total, n); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user