func (b *Builder) Run() error {
	// Parse the Dockerfile.
	dockerfile, err := os.Open(b.dockerfilePath)
	if err != nil {
		return fmt.Errorf("unable to open Dockerfile: %s", err)
	}
	defer dockerfile.Close()

	commands, err := parser.Parse(dockerfile)
	if err != nil {
		return fmt.Errorf("unable to parse Dockerfile: %s", err)
	}

	if len(commands) == 0 {
		return fmt.Errorf("no commands found in Dockerfile")
	}

	for i, command := range commands {
		if err := b.dispatch(i, command); err != nil {
			return err
		}
	}

	// create container and commit if we need to (because of trailing
	// metadata directives).
	if b.uncommitted && !b.probeCache() {

		b.containerID, err = b.createContainer([]string{"/bin/sh", "-c"}, []string{"#(nop)"}, false)
		if err != nil {
			return fmt.Errorf("unable to create container: %s", err)
		}

		if err := b.commit(); err != nil {
			return fmt.Errorf("unable to commit container image: %s", err)
		}
	}

	imageName := b.imageID
	if named, hasName := b.ref.(reference.Named); hasName {
		imageName = b.ref.String()

		var tag string
		if tagged, isTagged := named.(reference.Tagged); isTagged {
			tag = tagged.Tag()
		}
		if err := b.setTag(b.imageID, named.Name(), tag); err != nil {
			return fmt.Errorf("unable to tag built image: %s", err)
		}
	}

	fmt.Fprintf(b.out, "Successfully built %s\n", imageName)

	return nil
}
// Run executes the build process.
Run executes the build process.
// Run executes the build process .
func (b *Builder) Run() error {
	dockerfile, err := os.Open(b.dockerfilePath)
	if err != nil {
		return fmt.Errorf("unable to open Dockerfile: %s", err)
	}
	defer dockerfile.Close()
	commands, err := parser.Parse(dockerfile)
	if err != nil {
		return fmt.Errorf("unable to parse Dockerfile: %s", err)
	}
	if len(commands) == 0 {
		return fmt.Errorf("no commands found in Dockerfile")
	}
	for i, command := range commands {
		if err := b.dispatch(i, command); err != nil {
			return err
		}
	}
	if b.uncommitted && !b.probeCache() {
		b.containerID, err = b.createContainer([]string{"/bin/sh", "-c"}, []string{"#(nop)"}, false)
		if err != nil {
			return fmt.Errorf("unable to create container: %s", err)
		}
		if err := b.commit(); err != nil {
			return fmt.Errorf("unable to commit container image: %s", err)
		}
	}
	imageName := b.imageID
	if named, hasName := b.ref.(reference.Named); hasName {
		imageName = b.ref.String()
		var tag string
		if tagged, isTagged := named.(reference.Tagged); isTagged {
			tag = tagged.Tag()
		}
		if err := b.setTag(b.imageID, named.Name(), tag); err != nil {
			return fmt.Errorf("unable to tag built image: %s", err)
		}
	}
	fmt.Fprintf(b.out, "Successfully built %s\n", imageName)
	return nil
}
func ( b * Builder ) Run ( ) error { dockerfile , err := os . Open ( b . dockerfilePath ) if err != nil { return fmt . Errorf ( " " , err ) } defer dockerfile . Close ( ) commands , err := parser . Parse ( dockerfile ) if err != nil { return fmt . Errorf ( " " , err ) } if len ( commands ) == 0 { return fmt . Errorf ( " " ) } for i , command := range commands { if err := b . dispatch ( i , command ) ; err != nil { return err } } if b . uncommitted && ! b . probeCache ( ) { b . containerID , err = b . createContainer ( [ ] string { " " , " " } , [ ] string { " " } , false ) if err != nil { return fmt . Errorf ( " " , err ) } if err := b . commit ( ) ; err != nil { return fmt . Errorf ( " " , err ) } } imageName := b . imageID if named , hasName := b . ref . ( reference . Named ) ; hasName { imageName = b . ref . String ( ) var tag string if tagged , isTagged := named . ( reference . Tagged ) ; isTagged { tag = tagged . Tag ( ) } if err := b . setTag ( b . imageID , named . Name ( ) , tag ) ; err != nil { return fmt . Errorf ( " " , err ) } } fmt . Fprintf ( b . out , " \n " , imageName ) return nil }
Run executes the build process.
Run executes the build process .
// Parse the Dockerfile. // create container and commit if we need to (because of trailing // metadata directives).