Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

separate the image build and export phases #994

Merged
merged 2 commits into from
Jun 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ prog/netcheck/netcheck
tools/bin
tools/build
releases
.weaver.uptodate
.weavedns.uptodate
.weaveexec.uptodate
weave.tar
weavedns.tar
weaveexec.tar
prog/weaveexec/weave
prog/weaveexec/weaveproxy
prog/weaveexec/weavewait
Expand Down
31 changes: 18 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@ NETCHECK_EXE=prog/netcheck/netcheck

EXES=$(WEAVER_EXE) $(WEAVEDNS_EXE) $(SIGPROXY_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE) $(NETCHECK_EXE)

WEAVER_UPTODATE=.weaver.uptodate
WEAVEDNS_UPTODATE=.weavedns.uptodate
WEAVEEXEC_UPTODATE=.weaveexec.uptodate

IMAGES_UPTODATE=$(WEAVER_UPTODATE) $(WEAVEDNS_UPTODATE) $(WEAVEEXEC_UPTODATE)

WEAVER_IMAGE=$(DOCKERHUB_USER)/weave
WEAVEDNS_IMAGE=$(DOCKERHUB_USER)/weavedns
WEAVEEXEC_IMAGE=$(DOCKERHUB_USER)/weaveexec

IMAGES=$(WEAVER_IMAGE) $(WEAVEDNS_IMAGE) $(WEAVEEXEC_IMAGE)

WEAVER_EXPORT=weave.tar
WEAVEDNS_EXPORT=weavedns.tar
WEAVEEXEC_EXPORT=weaveexec.tar

EXPORTS=$(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVEEXEC_EXPORT)
WEAVE_EXPORT=weave.tar

WEAVEEXEC_DOCKER_VERSION=1.3.1
DOCKER_DISTRIB=prog/weaveexec/docker-$(WEAVEEXEC_DOCKER_VERSION).tgz
DOCKER_DISTRIB_URL=https://get.docker.com/builds/Linux/x86_64/docker-$(WEAVEEXEC_DOCKER_VERSION).tgz

all: $(EXPORTS)
all: $(WEAVE_EXPORT)

travis: $(EXES)

Expand Down Expand Up @@ -66,23 +68,26 @@ $(SIGPROXY_EXE): prog/sigproxy/main.go
$(WEAVEWAIT_EXE): prog/weavewait/main.go
go build -o $@ ./$(@D)

$(WEAVER_EXPORT): prog/weaver/Dockerfile $(WEAVER_EXE)
$(WEAVER_UPTODATE): prog/weaver/Dockerfile $(WEAVER_EXE)
$(SUDO) docker build -t $(WEAVER_IMAGE) prog/weaver
$(SUDO) docker save $(WEAVER_IMAGE):latest > $@
touch $@

$(WEAVEDNS_EXPORT): prog/weavedns/Dockerfile $(WEAVEDNS_EXE)
$(WEAVEDNS_UPTODATE): prog/weavedns/Dockerfile $(WEAVEDNS_EXE)
$(SUDO) docker build -t $(WEAVEDNS_IMAGE) prog/weavedns
$(SUDO) docker save $(WEAVEDNS_IMAGE):latest > $@
touch $@

$(WEAVEEXEC_EXPORT): prog/weaveexec/Dockerfile $(DOCKER_DISTRIB) weave $(SIGPROXY_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE) $(NETCHECK_EXE)
$(WEAVEEXEC_UPTODATE): prog/weaveexec/Dockerfile $(DOCKER_DISTRIB) weave $(SIGPROXY_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE) $(NETCHECK_EXE)
cp weave prog/weaveexec/weave
cp $(SIGPROXY_EXE) prog/weaveexec/sigproxy
cp $(WEAVEPROXY_EXE) prog/weaveexec/weaveproxy
cp $(WEAVEWAIT_EXE) prog/weaveexec/weavewait
cp $(NETCHECK_EXE) prog/weaveexec/netcheck
cp $(DOCKER_DISTRIB) prog/weaveexec/docker.tgz
$(SUDO) docker build -t $(WEAVEEXEC_IMAGE) prog/weaveexec
$(SUDO) docker save $(WEAVEEXEC_IMAGE):latest > $@
touch $@

$(WEAVE_EXPORT): $(IMAGES_UPTODATE)
$(SUDO) docker save $(addsuffix :latest,$(IMAGES)) > $@

$(DOCKER_DISTRIB):
curl -o $(DOCKER_DISTRIB) $(DOCKER_DISTRIB_URL)
Expand Down Expand Up @@ -112,7 +117,7 @@ publish: $(PUBLISH)

clean:
-$(SUDO) docker rmi $(IMAGES)
rm -f $(EXES) $(EXPORTS)
rm -f $(EXES) $(IMAGES_UPTODATE) $(WEAVE_EXPORT)
rm -f test/tls/*.pem

build:
Expand Down
5 changes: 4 additions & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM ubuntu

RUN apt-get -y update && apt-get -y install --no-install-recommends build-essential git ca-certificates docker.io mercurial libpcap-dev curl make pkg-config gcc bison flex
RUN apt-get -y update && apt-get -y install --no-install-recommends ca-certificates apt-transport-https
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
RUN echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
RUN apt-get -y update && apt-get -y install --no-install-recommends build-essential git lxc-docker-1.3.1 mercurial libpcap-dev curl make pkg-config gcc bison flex

# When doing a build in a container, "apt-get update" happens twice,
# which can be a very significant overhead for incremental builds.
Expand Down
11 changes: 4 additions & 7 deletions site/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ $ make

This will build the weave components and package them into three
Docker images (`weaveworks/weave`, `weaveworks/weavedns`, and
`weaveworks/weaveexec`). These are then exported (as `weave.tar`,
`weavedns.tar` and `weaveexec.tar`).
`weaveworks/weaveexec`). These are then exported as `weave.tar`.

## Building in a Docker container

Expand Down Expand Up @@ -171,15 +170,13 @@ you can do so with
$ vagrant ssh -c 'make -C src/github.com/weaveworks/weave'
```

you should then find container snapshot tarballs in the top-level
directory. You can use these snapshots with `docker load` against a
different host, e.g.
you should then find a `weave.tar` container snapshot tarball in the
top-level directory. You can use that snapshot with `docker load`
against a different host, e.g.

```bash
$ export DOCKER_HOST=tcp://<HOST:PORT>
$ docker load < weave.tar
$ docker load < weavedns.tar
$ docker load < weaveexec.tar
```

You can provide extra Vagrant configuration by putting a file
Expand Down
2 changes: 0 additions & 2 deletions test/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ echo "Copying weave images, scripts, and certificates to hosts, and"
echo " prefetch test images"
for HOST in $HOSTS; do
docker_on $HOST load -i ../weave.tar
docker_on $HOST load -i ../weavedns.tar
docker_on $HOST load -i ../weaveexec.tar
run_on $HOST mkdir -p bin
cat ../bin/docker-ns | run_on $HOST sh -c "cat > $DOCKER_NS"
cat ../weave | run_on $HOST sh -c "cat > ./weave"
Expand Down