package/docker-engine: introduce option to build CLI client statically
authorChristian Stewart <christian@paral.in>
Sun, 19 Mar 2017 06:20:42 +0000 (02:20 -0400)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sun, 19 Mar 2017 20:23:40 +0000 (21:23 +0100)
This is useful when bind-mounting the docker client binary into
containers for a docker-in-docker setup.

The Docker CLI communicates with the daemon over a socket. It is
sometimes useful to bind-mount the Docker CLI and socket into containers at
run-time, so that scripts within the containers can call the Docker API
in the host using a client compatible with the host daemon.

Signed-off-by: Christian Stewart <christian@paral.in>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/docker-engine/Config.in
package/docker-engine/docker-engine.mk

index 1879a56fddead9ee99feb4313553e72c5ce69336..7cf0d9e1ae59e49328fe84710f5cd8965a2688a7 100644 (file)
@@ -25,6 +25,12 @@ config BR2_PACKAGE_DOCKER_ENGINE_DAEMON
 config BR2_PACKAGE_DOCKER_ENGINE_EXPERIMENTAL
        bool "build experimental features"
 
+config BR2_PACKAGE_DOCKER_ENGINE_STATIC_CLIENT
+       bool "build static client"
+       depends on !BR2_STATIC_LIBS
+       help
+         Build a static docker client.
+
 if BR2_PACKAGE_DOCKER_ENGINE_DAEMON
 
 config BR2_PACKAGE_DOCKER_ENGINE_DRIVER_BTRFS
index 7f7840b7f6e4e18c44f60c0f15b2e163ce9aaecb..bf6f6a4b0dc61ed67037466d4483bff4a2d98e2a 100644 (file)
@@ -28,8 +28,13 @@ DOCKER_ENGINE_GLDFLAGS = \
 
 ifeq ($(BR2_STATIC_LIBS),y)
 DOCKER_ENGINE_GLDFLAGS += -extldflags '-static'
+else
+ifeq ($(BR2_PACKAGE_DOCKER_ENGINE_STATIC_CLIENT),y)
+DOCKER_ENGINE_GLDFLAGS_DOCKER += -extldflags '-static'
+endif
 endif
 
+
 DOCKER_ENGINE_BUILD_TAGS = cgo exclude_graphdriver_zfs autogen
 DOCKER_ENGINE_BUILD_TARGETS = docker
 
@@ -100,7 +105,7 @@ define DOCKER_ENGINE_BUILD_CMDS
                $(HOST_DIR)/usr/bin/go build -v \
                        -o $(@D)/bin/$(target) \
                        -tags "$(DOCKER_ENGINE_BUILD_TAGS)" \
-                       -ldflags "$(DOCKER_ENGINE_GLDFLAGS)" \
+                       -ldflags "$(DOCKER_ENGINE_GLDFLAGS) $(DOCKER_ENGINE_GLDFLAGS_$(call UPPERCASE,$(target)))" \
                        github.com/docker/docker/cmd/$(target)
        )
 endef