diff --git a/Makefile b/Makefile index c9e8283af..4291486dd 100644 --- a/Makefile +++ b/Makefile @@ -91,6 +91,7 @@ $(SCOPE_EXE) $(RUNSVINIT) lint tests shell prog/staticui/staticui.go prog/extern $(SUDO) docker run $(RM) $(RUN_FLAGS) \ -v $(shell pwd):/go/src/github.com/weaveworks/scope \ -v $(shell pwd)/.pkg:/go/pkg \ + -u $(shell id -u ${USER}):$(shell id -g ${USER}) \ --net=host \ -e GOARCH -e GOOS -e CIRCLECI -e CIRCLE_BUILD_NUM -e CIRCLE_NODE_TOTAL \ -e CIRCLE_NODE_INDEX -e COVERDIR -e SLOW -e TESTDIRS \ diff --git a/backend/build.sh b/backend/build.sh index f5fc7d543..872422c7c 100755 --- a/backend/build.sh +++ b/backend/build.sh @@ -7,14 +7,4 @@ SCOPE_SRC=$GOPATH/src/github.com/weaveworks/scope # Mount the scope repo: # -v $(pwd):/go/src/github.com/weaveworks/scope -# If we run make directly, any files created on the bind mount -# will have awkward ownership. So we switch to a user with the -# same user and group IDs as source directory. We have to set a -# few things up so that sudo works without complaining later on. -uid=$(stat --format="%u" "$SCOPE_SRC") -gid=$(stat --format="%g" "$SCOPE_SRC") -echo "weave:x:$uid:$gid::$SCOPE_SRC:/bin/sh" >>/etc/passwd -echo "weave:*:::::::" >>/etc/shadow -echo "weave ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers - -su weave -c "PATH=$PATH make -C $SCOPE_SRC BUILD_IN_CONTAINER=false $*" +make -C $SCOPE_SRC BUILD_IN_CONTAINER=false $*