From 7226b26e8e70b9f45fe8c5184fb6e59fde2ef947 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 12 May 2017 15:50:57 +0000 Subject: [PATCH 1/3] Reorganise Docker image layers to slim weave-kube --- .gitignore | 4 ++-- Makefile | 8 ++++---- prog/weaveexec/Dockerfile.template | 29 +++-------------------------- prog/weaver/Dockerfile.template | 29 +++++++++++++++++++++++++++-- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 3da087b3..47c9056e 100644 --- a/.gitignore +++ b/.gitignore @@ -53,14 +53,14 @@ testing/runner/runner releases .*.uptodate weave*.tar.gz -prog/weaveexec/weave +prog/weaver/weave prog/weaveexec/weavehosts prog/weaveexec/weaveproxy prog/weaveexec/weavewait prog/weaveexec/weavewait_noop prog/weaveexec/weavewait_nomcast prog/weaveexec/sigproxy -prog/weaveexec/weaveutil +prog/weaver/weaveutil prog/weaveexec/docker* Vagrantfile.local test/tls/tls diff --git a/Makefile b/Makefile index 95c6f0d0..404f81d2 100644 --- a/Makefile +++ b/Makefile @@ -248,17 +248,17 @@ else endif # The targets below builds the weave images -$(WEAVER_UPTODATE): prog/weaver/Dockerfile.$(DOCKERHUB_USER) $(WEAVER_EXE) $(WEAVEEXEC_UPTODATE) +$(WEAVER_UPTODATE): prog/weaver/Dockerfile.$(DOCKERHUB_USER) $(WEAVER_EXE) weave $(WEAVEUTIL_EXE) + cp $(WEAVEUTIL_EXE) prog/weaver/weaveutil + cp weave prog/weaver/weave $(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker build -f prog/weaver/Dockerfile.$(DOCKERHUB_USER) -t $(WEAVER_IMAGE) prog/weaver touch $@ -$(WEAVEEXEC_UPTODATE): prog/weaveexec/Dockerfile.$(DOCKERHUB_USER) prog/weaveexec/symlink $(DOCKER_DISTRIB) weave $(SIGPROXY_EXE) $(WEAVEWAIT_EXE) $(WEAVEWAIT_NOOP_EXE) $(WEAVEWAIT_NOMCAST_EXE) $(WEAVEUTIL_EXE) - cp weave prog/weaveexec/weave +$(WEAVEEXEC_UPTODATE): prog/weaveexec/Dockerfile.$(DOCKERHUB_USER) prog/weaveexec/symlink $(DOCKER_DISTRIB) $(SIGPROXY_EXE) $(WEAVEWAIT_EXE) $(WEAVEWAIT_NOOP_EXE) $(WEAVEWAIT_NOMCAST_EXE) $(WEAVER_UPTODATE) cp $(SIGPROXY_EXE) prog/weaveexec/sigproxy cp $(WEAVEWAIT_EXE) prog/weaveexec/weavewait cp $(WEAVEWAIT_NOOP_EXE) prog/weaveexec/weavewait_noop cp $(WEAVEWAIT_NOMCAST_EXE) prog/weaveexec/weavewait_nomcast - cp $(WEAVEUTIL_EXE) prog/weaveexec/weaveutil tar -xf $(DOCKER_DISTRIB) usr/local/bin/docker -O > prog/weaveexec/docker chmod +x prog/weaveexec/docker $(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker build -f prog/weaveexec/Dockerfile.$(DOCKERHUB_USER) -t $(WEAVEEXEC_IMAGE) prog/weaveexec diff --git a/prog/weaveexec/Dockerfile.template b/prog/weaveexec/Dockerfile.template index 716dda01..1f9e8bd6 100644 --- a/prog/weaveexec/Dockerfile.template +++ b/prog/weaveexec/Dockerfile.template @@ -1,32 +1,9 @@ -FROM ALPINE_BASEIMAGE - -# If we're building for another architecture than amd64, the CROSS_BUILD_ placeholder is removed so e.g. CROSS_BUILD_COPY turns into COPY -# If we're building normally, for amd64, CROSS_BUILD lines are removed -CROSS_BUILD_COPY qemu-QEMUARCH-static /usr/bin/ - -LABEL maintainer "Weaveworks Inc " -LABEL works.weave.role=system \ - org.label-schema.name="Weave Net" \ - org.label-schema.description="Weave Net creates a virtual network that connects Docker containers across multiple hosts and enables their automatic discovery" \ - org.label-schema.url="https://weave.works" \ - org.label-schema.vcs-url="https://github.com/weaveworks/weave" \ - org.label-schema.vendor="Weaveworks" +FROM DOCKERHUB_USER/weaveARCH_EXT ENTRYPOINT ["/home/weave/sigproxy", "/home/weave/weave"] -RUN apk add --update \ - curl \ - ethtool \ - iptables \ - ipset \ - iproute2 \ - util-linux \ - conntrack-tools \ - bind-tools \ - && rm -rf /var/cache/apk/* - -ADD ./weave ./sigproxy ./symlink /home/weave/ -ADD ./weaveutil ./docker /usr/bin/ +ADD ./sigproxy ./symlink /home/weave/ +ADD ./docker /usr/bin/ ADD ./weavewait /w/w ADD ./weavewait_noop /w-noop/w ADD ./weavewait_nomcast /w-nomcast/w diff --git a/prog/weaver/Dockerfile.template b/prog/weaver/Dockerfile.template index 78b95c36..c01bde16 100644 --- a/prog/weaver/Dockerfile.template +++ b/prog/weaver/Dockerfile.template @@ -1,5 +1,30 @@ -FROM DOCKERHUB_USER/weaveexecARCH_EXT -ADD ./weaver /home/weave/ +FROM ALPINE_BASEIMAGE + +# If we're building for another architecture than amd64, the CROSS_BUILD_ placeholder is removed so e.g. CROSS_BUILD_COPY turns into COPY +# If we're building normally, for amd64, CROSS_BUILD lines are removed +CROSS_BUILD_COPY qemu-QEMUARCH-static /usr/bin/ + +LABEL maintainer "Weaveworks Inc " +LABEL works.weave.role=system \ + org.label-schema.name="Weave Net" \ + org.label-schema.description="Weave Net creates a virtual network that connects Docker containers across multiple hosts and enables their automatic discovery" \ + org.label-schema.url="https://weave.works" \ + org.label-schema.vcs-url="https://github.com/weaveworks/weave" \ + org.label-schema.vendor="Weaveworks" + +RUN apk add --update \ + curl \ + ethtool \ + iptables \ + ipset \ + iproute2 \ + util-linux \ + conntrack-tools \ + bind-tools \ + && rm -rf /var/cache/apk/* + +ADD ./weave ./weaver /home/weave/ +ADD ./weaveutil /usr/bin/ ADD weavedata.db /weavedb/ COPY ca-certificates.crt /etc/ssl/certs/ ENTRYPOINT ["/home/weave/weaver"] From 06caf03d7073ce926b92f4e766ab49c09667174a Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 12 May 2017 16:51:39 +0000 Subject: [PATCH 2/3] Need the workdir for weave container too --- prog/weaver/Dockerfile.template | 1 + 1 file changed, 1 insertion(+) diff --git a/prog/weaver/Dockerfile.template b/prog/weaver/Dockerfile.template index c01bde16..6be43c42 100644 --- a/prog/weaver/Dockerfile.template +++ b/prog/weaver/Dockerfile.template @@ -28,3 +28,4 @@ ADD ./weaveutil /usr/bin/ ADD weavedata.db /weavedb/ COPY ca-certificates.crt /etc/ssl/certs/ ENTRYPOINT ["/home/weave/weaver"] +WORKDIR /home/weave From 1e2dc43df6e3cf336b0d785864dd5a1825f4f829 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sat, 13 May 2017 13:52:42 +0100 Subject: [PATCH 3/3] Don't check docker version when run --local The standard case for --local is when the weave script in the weaveexec container is run by the weave script, which has just checked the version. --local is also used from weave-kube where we don't mount the docker socket and therefore cannot check. Since --local is undocumented we will not worry about any other cases; the worst that can happen is a confusing error message. --- weave | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/weave b/weave index 0b4a66fb..6daf9340 100755 --- a/weave +++ b/weave @@ -219,8 +219,6 @@ kill_container() { # main ###################################################################### -check_docker_version - [ "$1" = "--local" ] && shift 1 && IS_LOCAL=1 # "--help|help" are special because we always want to process them @@ -245,6 +243,7 @@ elif [ "$1" = "env" -a "$2" = "--restore" ] ; then fi if [ -z "$IS_LOCAL" ] ; then + check_docker_version exec_remote "$@" exit $? fi