Skip to content

Commit

Permalink
Make scope work with weave master.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Wilkie committed Oct 19, 2015
1 parent 6c336bd commit aa33b0a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ probe/scope-probe
docker/scope-app
docker/scope-probe
docker/docker*
docker/weave
docker/runsvinit
experimental/bridge/bridge
experimental/demoprobe/demoprobe
Expand Down
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ all: $(SCOPE_EXPORT)
$(DOCKER_DISTRIB):
curl -o $(DOCKER_DISTRIB) $(DOCKER_DISTRIB_URL)

docker/weave:
curl -L git.io/weave -o docker/weave
chmod u+x docker/weave

$(SCOPE_EXPORT): $(APP_EXE) $(PROBE_EXE) $(DOCKER_DISTRIB) docker/weave $(RUNSVINIT) docker/Dockerfile docker/run-app docker/run-probe docker/entrypoint.sh
$(SCOPE_EXPORT): $(APP_EXE) $(PROBE_EXE) $(DOCKER_DISTRIB) $(RUNSVINIT) docker/Dockerfile docker/run-app docker/run-probe docker/entrypoint.sh
@if [ -z '$(DOCKER_SQUASH)' ] ; then echo "Please install docker-squash by running 'make deps' (and make sure GOPATH/bin is in your PATH)." && exit 1 ; fi
cp $(APP_EXE) $(PROBE_EXE) docker/
cp $(DOCKER_DISTRIB) docker/docker.tgz
Expand Down Expand Up @@ -94,7 +90,7 @@ frontend: $(SCOPE_UI_BUILD_UPTODATE)

clean:
go clean ./...
rm -rf $(SCOPE_EXPORT) $(SCOPE_UI_BUILD_EXPORT) $(APP_EXE) $(PROBE_EXE) client/build/app.js docker/weave
rm -rf $(SCOPE_EXPORT) $(SCOPE_UI_BUILD_EXPORT) $(APP_EXE) $(PROBE_EXE) client/build/app.js

deps:
go get -u -f -tags netgo \
Expand Down
1 change: 0 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ RUN echo "http://dl-4.alpinelinux.org/alpine/edge/testing" >>/etc/apk/repositori
apk add --update runit conntrack-tools iproute2 util-linux curl && \
rm -rf /var/cache/apk/*
ADD ./docker.tgz /
ADD ./weave /usr/bin/
COPY ./scope-app ./scope-probe ./runsvinit ./entrypoint.sh /home/weave/
COPY ./run-app /etc/service/app/run
COPY ./run-probe /etc/service/probe/run
Expand Down
34 changes: 23 additions & 11 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ DOMAIN=weave.local
IP_REGEXP="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"

container_ip() {
if ! status=$(docker inspect --format='{{.State.Running}} {{.NetworkSettings.IPAddress}}' $1 2>/dev/null); then
echo "$2" >&2
if ! status=$(docker inspect --format='{{.State.Running}} {{.HostConfig.NetworkMode}}' $1 2>/dev/null); then
echo "Container $1 not found" >&2
return 1
fi
case "$status" in
"true ")
echo "$1 container has no IP address; is Docker networking enabled?" >&2
return 1
"true host")
CONTAINER_IP="127.0.0.1"
return 0
;;
true*)
CONTAINER_IP="${status#true }"
"true default" | "true bridge")
CONTAINER_IP="$(docker inspect --format='{{.NetworkSettings.IPAddress}}' $1 2>/dev/null)"
return 0
;;
*)
echo "$3" >&2
echo "Container $1 not running" >&2
return 1
;;
esac
Expand All @@ -44,11 +45,22 @@ docker_bridge_ip() {
echo ${DOCKER_BRIDGE_IP#inet }
}

# Run `weave` in the weave exec container
weave() {
WEAVEXEC_IMAGE=$(docker inspect --format='{{.Config.Image}}' weave | sed 's/\/weave/\/weaveexec/')
docker run -t --rm --privileged --net=host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /proc:/hostproc \
-e PROCFS=/hostproc \
$WEAVEXEC_IMAGE --local "$@"
}

# Run `weave expose` if it's not already exposed.
weave_expose() {
status=$(weave --local ps weave:expose | awk '{print $3}' 2>/dev/null)
status=$(weave ps weave:expose | awk '{print $3}' 2>/dev/null)
if [ "$status" = "" ]; then
weave --local expose
echo "Exposing host to weave network."
weave expose
fi
}

Expand Down Expand Up @@ -127,7 +139,7 @@ if is_running $WEAVE_CONTAINER_NAME; then
exit 1
else
for ip in $IP_ADDRS; do
weave --local dns-add $ip $CONTAINER -h $HOSTNAME.$DOMAIN
weave dns-add $ip $CONTAINER -h $HOSTNAME.$DOMAIN
done
fi
fi
Expand Down

0 comments on commit aa33b0a

Please sign in to comment.