docker/docker — pull request #7377 by tianon (2014-08-01 17:57:53+00:00)
Title: Add a "daemon" build tag and toggle it with the already-existing "DOCKER_CLIENTONLY" build variable

This works mostly by refactoring our "main" package to be careful about what it imports based on the daemon build tag. :)

(The diff doesn't make it obvious, but all I've really done is move code around here.)

Also, I've updated Travis to test "client-only" compilation after it tests the daemon version.

Daemon-including filesizes:
```console
$ AUTO_GOPATH=1 ./hack/make.sh dynbinary
...
$ ls -lAFh bundles/1.1.2-dev/dynbinary/docker*-1.1.2-dev
-rwxrwxr-x 1 tianon tianon 11M Aug 1 11:37 bundles/1.1.2-dev/dynbinary/docker-1.1.2-dev*
-rwxrwxr-x 1 tianon tianon 7.0M Aug 1 11:37 bundles/1.1.2-dev/dynbinary/dockerinit-1.1.2-dev*
```
And now client-only:
```console
$ AUTO_GOPATH=1 DOCKER_CLIENTONLY=1 ./hack/make.sh dynbinary
...
$ ls -lAFh bundles/1.1.2-dev/dynbinary/docker*-1.1.2-dev
-rwxrwxr-x 1 tianon tianon 6.7M Aug 1 11:39 bundles/1.1.2-dev/dynbinary/docker-1.1.2-dev*
```

From 11M down to 6.7M for client-only on linux/amd64. When I cross-compiled for Darwin using dynbinary, it was 6.5M.

This is as discussed on #7320.

With this change, here's how close we are to a compiling Windows client: (part of which is likely fixing more imports to be gated by the "daemon" build tag but I think that "pkg/term" error is actually something we need to fix :P)
```console
root@e7f71f634ab9:/go/src/github.com/docker/docker# GOOS=windows AUTO_GOPATH=1 DOCKER_CLIENTONLY=1 ./hack/make.sh dynbinary
# WARNING! I don't seem to be running in the Docker container.
# The result of this command might be an incorrect build, and will not be
# officially supported.
#
# Try this instead: make all
#

bundles/1.1.2-dev already exists. Removing.

---> Making bundle: dynbinary (in bundles/1.1.2-dev/dynbinary)
# github.com/docker/docker/pkg/term
.gopath/src/github.com/docker/docker/pkg/term/term.go:16: undefined: Termios
# github.com/docker/docker/pkg/system
.gopath/src/github.com/docker/docker/pkg/system/stat_unsupported.go:7: undefined: syscall.Stat_t
.gopath/src/github.com/docker/docker/pkg/system/stat_unsupported.go:11: undefined: syscall.Stat_t
# github.com/docker/libcontainer/devices
vendor/src/github.com/docker/libcontainer/devices/devices.go:65: undefined: syscall.Stat_t
```