Browse code

Update the UI for docker build

Guillaume J. Charmes authored on 2013/05/29 05:38:40
Showing 1 changed files
... ...
@@ -112,9 +112,8 @@ func (cli *DockerCli) CmdInsert(args ...string) error {
112 112
 }
113 113
 
114 114
 func (cli *DockerCli) CmdBuild(args ...string) error {
115
-	cmd := Subcmd("build", "[OPTIONS]", "Build an image from a Dockerfile")
116
-	fileName := cmd.String("f", "Dockerfile", "Use file as Dockerfile. Can be '-' for stdin")
117
-	contextPath := cmd.String("c", "", "Use the specified directory as context for the build")
115
+	cmd := Subcmd("build", "[OPTIONS] [CONTEXT]", "Build an image from a Dockerfile")
116
+	fileName := cmd.String("f", "Dockerfile", "Use `file` as Dockerfile. Can be '-' for stdin")
118 117
 	if err := cmd.Parse(args); err != nil {
119 118
 		return nil
120 119
 	}
... ...
@@ -146,14 +145,16 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
146 146
 	}
147 147
 	multipartBody = io.MultiReader(multipartBody, file)
148 148
 
149
+	compression := Bzip2
150
+
149 151
 	// Create a FormFile multipart for the context if needed
150
-	if *contextPath != "" {
152
+	if cmd.Arg(0) != "" {
151 153
 		// FIXME: Use NewTempArchive in order to have the size and avoid too much memory usage?
152
-		context, err := Tar(*contextPath, Bzip2)
154
+		context, err := Tar(cmd.Arg(0), compression)
153 155
 		if err != nil {
154 156
 			return err
155 157
 		}
156
-		if _, err := w.CreateFormFile("Context", *contextPath+".tar.bz2"); err != nil {
158
+		if _, err := w.CreateFormFile("Context", cmd.Arg(0)+"."+compression.Extension()); err != nil {
157 159
 			return err
158 160
 		}
159 161
 		multipartBody = io.MultiReader(multipartBody, utils.ProgressReader(ioutil.NopCloser(context), -1, os.Stdout, "Uploading Context %v/%v (%v)"))
... ...
@@ -165,6 +166,9 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
165 165
 		return err
166 166
 	}
167 167
 	req.Header.Set("Content-Type", w.FormDataContentType())
168
+	if cmd.Arg(0) != "" {
169
+		req.Header.Set("X-Docker-Context-Compression", compression.Flag())
170
+	}
168 171
 
169 172
 	resp, err := http.DefaultClient.Do(req)
170 173
 	if err != nil {