From 7009d6c6ddc2acc77e7caa227c08ecf29d747298 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Mon, 25 Mar 2013 23:48:46 +0200 Subject: [PATCH 1/7] introduce top-level Makefile to build the docker binary --- .gitignore | 1 + Makefile | 33 +++++++++++++++++++++++++++++++++ README.md | 16 ++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index cabd399067..809fa8e268 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ command-line-arguments.test .flymake* docker.test auth/auth.test +build/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..82cbb2286d --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +DOCKER_PACKAGE := github.com/dotcloud/docker + +BUILD_DIR := $(CURDIR)/build + +GOPATH ?= $(BUILD_DIR) +export GOPATH + +SRC_DIR := $(GOPATH)/src + +DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE) +DOCKER_MAIN := $(DOCKER_DIR)/docker + +DOCKER_BIN := $(CURDIR)/bin/docker + +.PHONY: all clean + +all: $(DOCKER_BIN) + +$(DOCKER_BIN): $(DOCKER_DIR) + @mkdir -p $(dir $@) + (cd $(DOCKER_MAIN); go get; go build -o $@) + +$(DOCKER_DIR): + @mkdir -p $(dir $@) + @ln -sf $(CURDIR)/ $@ + +clean: + @rm -rf $(dir $(DOCKER_BIN)) +ifeq ($(GOPATH), $(BUILD_DIR)) + @rm -rf $(BUILD_DIR) +else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR))) + @rm -f $(DOCKER_DIR) +endif diff --git a/README.md b/README.md index c955a1dcf2..0ff28ec101 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,22 @@ Under the hood, Docker is built on the following components: Install instructions ================== +Building from source +-------------------- + +1. Make sure you have a [Go language](http://golang.org) compiler. + + On a Debian/wheezy or Ubuntu 12.10 install the package: + + ```bash + + $ sudo apt-get install golang-go + ``` + +2. Execute ``make`` + +3. Find your binary in ``bin/docker`` + Installing on Ubuntu 12.04 and 12.10 ------------------------------------ From 6b4bc971fd7ea03227f88b66168b884e2272aea6 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 00:15:37 +0200 Subject: [PATCH 2/7] add a test target --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 82cbb2286d..3b8b1e9249 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ DOCKER_MAIN := $(DOCKER_DIR)/docker DOCKER_BIN := $(CURDIR)/bin/docker -.PHONY: all clean +.PHONY: all clean test all: $(DOCKER_BIN) @@ -31,3 +31,6 @@ ifeq ($(GOPATH), $(BUILD_DIR)) else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR))) @rm -f $(DOCKER_DIR) endif + +test: all + (cd $(DOCKER_DIR); sudo -E go test) From a57b37ed0e1531e7cc7b8c91ecf73a904c067891 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 02:23:36 +0200 Subject: [PATCH 3/7] use .gopath/ instead of build/ --- .gitignore | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 809fa8e268..4bbbb2a127 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ command-line-arguments.test .flymake* docker.test auth/auth.test -build/ +.gopath/ diff --git a/Makefile b/Makefile index 3b8b1e9249..be67fcc232 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ DOCKER_PACKAGE := github.com/dotcloud/docker -BUILD_DIR := $(CURDIR)/build +BUILD_DIR := $(CURDIR)/.gopath GOPATH ?= $(BUILD_DIR) export GOPATH From 5a0010abe99869ffb4cb70917caa5ba35346e3e8 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 08:21:10 +0200 Subject: [PATCH 4/7] do not print executed commands --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index be67fcc232..793b14d543 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ all: $(DOCKER_BIN) $(DOCKER_BIN): $(DOCKER_DIR) @mkdir -p $(dir $@) - (cd $(DOCKER_MAIN); go get; go build -o $@) + @(cd $(DOCKER_MAIN); go get; go build -o $@) $(DOCKER_DIR): @mkdir -p $(dir $@) @@ -33,4 +33,4 @@ else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR))) endif test: all - (cd $(DOCKER_DIR); sudo -E go test) + @(cd $(DOCKER_DIR); sudo -E go test) From a26c58e27ef5ab1b017097fd8fc75d778d7c9eef Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 08:25:20 +0200 Subject: [PATCH 5/7] slightly re-phrase the build from source in README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ff28ec101..247d763e30 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,8 @@ Building from source 2. Execute ``make`` -3. Find your binary in ``bin/docker`` + This command will install all necessary dependencies and build the + executable that you can find in ``bin/docker`` Installing on Ubuntu 12.04 and 12.10 ------------------------------------ From 21f55419b73eaff72fe3383b4ee142b04e701372 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 08:28:35 +0200 Subject: [PATCH 6/7] allow for verbose output from go tools --- Makefile | 9 +++++++-- README.md | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 793b14d543..fa5b7a94a8 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,11 @@ BUILD_DIR := $(CURDIR)/.gopath GOPATH ?= $(BUILD_DIR) export GOPATH +GO_OPTIONS ?= +ifeq ($(VERBOSE), 1) +GO_OPTIONS += -v +endif + SRC_DIR := $(GOPATH)/src DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE) @@ -18,7 +23,7 @@ all: $(DOCKER_BIN) $(DOCKER_BIN): $(DOCKER_DIR) @mkdir -p $(dir $@) - @(cd $(DOCKER_MAIN); go get; go build -o $@) + @(cd $(DOCKER_MAIN); go get $(GO_OPTIONS); go build $(GO_OPTIONS) -o $@) $(DOCKER_DIR): @mkdir -p $(dir $@) @@ -33,4 +38,4 @@ else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR))) endif test: all - @(cd $(DOCKER_DIR); sudo -E go test) + @(cd $(DOCKER_DIR); sudo -E go test $(GO_OPTIONS)) diff --git a/README.md b/README.md index 247d763e30..3c3765fdc2 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,13 @@ Building from source This command will install all necessary dependencies and build the executable that you can find in ``bin/docker`` +3. Should you like to see what's happening, run ``make`` with ``VERBOSE=1`` parameter: + + ```bash + + $ make VERBOSE=1 + ``` + Installing on Ubuntu 12.04 and 12.10 ------------------------------------ From f961ec55e72ae068c6153f2d20da5295d8d0a4c1 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 16:30:01 +0200 Subject: [PATCH 7/7] print the location of the built binary --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fa5b7a94a8..e716762d31 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,8 @@ SRC_DIR := $(GOPATH)/src DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE) DOCKER_MAIN := $(DOCKER_DIR)/docker -DOCKER_BIN := $(CURDIR)/bin/docker +DOCKER_BIN_RELATIVE := bin/docker +DOCKER_BIN := $(CURDIR)/$(DOCKER_BIN_RELATIVE) .PHONY: all clean test @@ -24,6 +25,7 @@ all: $(DOCKER_BIN) $(DOCKER_BIN): $(DOCKER_DIR) @mkdir -p $(dir $@) @(cd $(DOCKER_MAIN); go get $(GO_OPTIONS); go build $(GO_OPTIONS) -o $@) + @echo $(DOCKER_BIN_RELATIVE) is created. $(DOCKER_DIR): @mkdir -p $(dir $@)