summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Vieux <victor.vieux@docker.com>2014-02-26 20:15:21 +0000
committerVictor Vieux <victor.vieux@docker.com>2014-02-26 20:15:21 +0000
commite68dcc55ba114627d521d15c19a1fcce61bd8de2 (patch)
tree567e0e845bc0eba2b5223f3074116a372cb59741
parentbde192bb80079ad89057a6df5ce676c5b3429901 (diff)
downloaddocker-move_git_clone_client_side.tar.gz
move git clone from daemon to clientmove_git_clone_client_side
Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
-rw-r--r--api/client.go25
-rw-r--r--api/server.go4
-rw-r--r--docs/sources/reference/api/docker_remote_api.rst5
-rw-r--r--utils/utils.go2
4 files changed, 31 insertions, 5 deletions
diff --git a/api/client.go b/api/client.go
index 2ea2dc44ea..2dce8eba33 100644
--- a/api/client.go
+++ b/api/client.go
@@ -161,17 +161,34 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
return err
}
context, err = archive.Generate("Dockerfile", string(dockerfile))
- } else if utils.IsURL(cmd.Arg(0)) || utils.IsGIT(cmd.Arg(0)) {
+ } else if utils.IsURL(cmd.Arg(0)) {
isRemote = true
} else {
- if _, err := os.Stat(cmd.Arg(0)); err != nil {
+ root := cmd.Arg(0)
+ if utils.IsGIT(root) {
+ remoteURL := cmd.Arg(0)
+ if !strings.HasPrefix(remoteURL, "git://") && !strings.HasPrefix(remoteURL, "git@") {
+ remoteURL = "https://" + remoteURL
+ }
+
+ root, err = ioutil.TempDir("", "docker-build-git")
+ if err != nil {
+ return err
+ }
+ defer os.RemoveAll(root)
+
+ if output, err := exec.Command("git", "clone", remoteURL, root).CombinedOutput(); err != nil {
+ return fmt.Errorf("Error trying to use git: %s (%s)", err, output)
+ }
+ }
+ if _, err := os.Stat(root); err != nil {
return err
}
- filename := path.Join(cmd.Arg(0), "Dockerfile")
+ filename := path.Join(root, "Dockerfile")
if _, err = os.Stat(filename); os.IsNotExist(err) {
return fmt.Errorf("no Dockerfile found in %s", cmd.Arg(0))
}
- context, err = archive.Tar(cmd.Arg(0), archive.Uncompressed)
+ context, err = archive.Tar(root, archive.Uncompressed)
}
var body io.Reader
// Setup an upload progress bar
diff --git a/api/server.go b/api/server.go
index b6beb45403..b0601c71c1 100644
--- a/api/server.go
+++ b/api/server.go
@@ -850,6 +850,10 @@ func postBuild(eng *engine.Engine, version version.Version, w http.ResponseWrite
}
}
+ if version.CreaterThanOrEqualTo("1.10") && utils.IsGIT(r.FormValue("remote")) {
+ return fmt.Errorf("Please clone locally and build using context")
+ }
+
if version.GreaterThanOrEqualTo("1.8") {
job.SetenvBool("json", true)
streamJSON(job, w, true)
diff --git a/docs/sources/reference/api/docker_remote_api.rst b/docs/sources/reference/api/docker_remote_api.rst
index 3733effaf8..e0f7935b45 100644
--- a/docs/sources/reference/api/docker_remote_api.rst
+++ b/docs/sources/reference/api/docker_remote_api.rst
@@ -51,6 +51,11 @@ What's new
**New!** You can now use the force parameter to force delete of an image, even if it's
tagged in multiple repositories.
+.. http:post:: /build
+
+ **Removed** When building a github repo, the Docker server will no longer
+ run the git clone for you. Please clone locally and build using context.
+
v1.9
****
diff --git a/utils/utils.go b/utils/utils.go
index f24e17c38e..43d4dc77fc 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -685,7 +685,7 @@ func IsURL(str string) bool {
}
func IsGIT(str string) bool {
- return strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "github.com/")
+ return strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "github.com/") || strings.HasPrefix(str, "git@github.com:")
}
// GetResolvConf opens and read the content of /etc/resolv.conf.