diff --git a/FIXME b/FIXME index b88757e229..e182d38d30 100644 --- a/FIXME +++ b/FIXME @@ -16,7 +16,6 @@ to put them - so we put them here :) * Unify build commands and regular commands * Move source code into src/ subdir for clarity * Clean up the Makefile, it's a mess -* docker buidl: show short IDs * docker build: on non-existent local path for ADD, don't show full absolute path on the host * mount into /dockerinit rather than /sbin/init * docker tag foo REPO:TAG diff --git a/buildfile.go b/buildfile.go index de350a8812..eb322d8176 100644 --- a/buildfile.go +++ b/buildfile.go @@ -101,6 +101,7 @@ func (b *buildFile) CmdRun(args string) error { if cache, err := b.srv.ImageGetCached(b.image, b.config); err != nil { return err } else if cache != nil { + fmt.Fprintf(b.out, " ---> Using cache\n") utils.Debugf("[BUILDER] Use cached version") b.image = cache.ID return nil @@ -185,6 +186,7 @@ func (b *buildFile) CmdAdd(args string) error { return err } b.tmpContainers[container.ID] = struct{}{} + fmt.Fprintf(b.out, " ---> Running in %s\n", utils.TruncateID(container.ID)) if err := container.EnsureMounted(); err != nil { return err @@ -235,6 +237,7 @@ func (b *buildFile) run() (string, error) { return "", err } b.tmpContainers[c.ID] = struct{}{} + fmt.Fprintf(b.out, " ---> Running in %s\n", utils.TruncateID(c.ID)) //start the container if err := c.Start(); err != nil { @@ -261,6 +264,7 @@ func (b *buildFile) commit(id string, autoCmd []string, comment string) error { if cache, err := b.srv.ImageGetCached(b.image, b.config); err != nil { return err } else if cache != nil { + fmt.Fprintf(b.out, " ---> Using cache\n") utils.Debugf("[BUILDER] Use cached version") b.image = cache.ID return nil @@ -274,6 +278,7 @@ func (b *buildFile) commit(id string, autoCmd []string, comment string) error { return err } b.tmpContainers[container.ID] = struct{}{} + fmt.Fprintf(b.out, " ---> Running in %s\n", utils.TruncateID(container.ID)) if err := container.EnsureMounted(); err != nil { return err @@ -314,6 +319,7 @@ func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) { b.context = name } file := bufio.NewReader(dockerfile) + stepN := 0 for { line, err := file.ReadString('\n') if err != nil { @@ -334,12 +340,13 @@ func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) { } instruction := strings.ToLower(strings.Trim(tmp[0], " ")) arguments := strings.Trim(tmp[1], " ") - - fmt.Fprintf(b.out, "%s %s (%s)\n", strings.ToUpper(instruction), arguments, b.image) + stepN += 1 + // FIXME: only count known instructions as build steps + fmt.Fprintf(b.out, "Step %d : %s %s\n", stepN, strings.ToUpper(instruction), arguments) method, exists := reflect.TypeOf(b).MethodByName("Cmd" + strings.ToUpper(instruction[:1]) + strings.ToLower(instruction[1:])) if !exists { - fmt.Fprintf(b.out, "Skipping unknown instruction %s\n", strings.ToUpper(instruction)) + fmt.Fprintf(b.out, "# Skipping unknown instruction %s\n", strings.ToUpper(instruction)) continue } ret := method.Func.Call([]reflect.Value{reflect.ValueOf(b), reflect.ValueOf(arguments)})[0].Interface() @@ -347,10 +354,10 @@ func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) { return "", ret.(error) } - fmt.Fprintf(b.out, "===> %v\n", b.image) + fmt.Fprintf(b.out, " ---> %v\n", utils.TruncateID(b.image)) } if b.image != "" { - fmt.Fprintf(b.out, "Build successful.\n===> %s\n", b.image) + fmt.Fprintf(b.out, "Successfully built %s\n", utils.TruncateID(b.image)) return b.image, nil } return "", fmt.Errorf("An error occured during the build\n") diff --git a/docs/sources/use/builder.rst b/docs/sources/use/builder.rst index f2e9ce97ce..c703fc7767 100644 --- a/docs/sources/use/builder.rst +++ b/docs/sources/use/builder.rst @@ -15,10 +15,18 @@ steps and commit them along the way, giving you a final image. 1. Usage ======== -To use Docker Builder, assemble the steps into a text file (commonly referred to -as a Dockerfile) and supply this to `docker build` on STDIN, like so: +To build an image from a source repository, create a description file called `Dockerfile` +at the root of your repository. This file will describe the steps to assemble +the image. - ``docker build - < Dockerfile`` +Then call `docker build` with the path of your source repository as argument: + + ``docker build .`` + +You can specify a repository and tag at which to save the new image if the +build succeeds: + + ``docker build -t shykes/myapp .`` Docker will run your steps one-by-one, committing the result if necessary, before finally outputting the ID of your new image.