From fc95067bd37af62ca74942bda1874807a1e3a634 Mon Sep 17 00:00:00 2001 From: Peter Bourgon Date: Thu, 10 Sep 2015 15:28:50 +0200 Subject: [PATCH 1/3] First cut of Docker build for backend --- .gitignore | 3 ++- Makefile | 8 +++++++- backend/Dockerfile | 5 +++++ backend/build.bash | 12 ++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 backend/Dockerfile create mode 100755 backend/build.bash diff --git a/.gitignore b/.gitignore index 830caffec..f76353492 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,5 @@ experimental/_integration/_integration *sublime-project *sublime-workspace *npm-debug.log - +backend/scope-app +backend/scope-probe diff --git a/Makefile b/Makefile index 3d7933137..4daa1611b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all deps static clean client-lint client-test client-sync +.PHONY: all deps static clean client-lint client-test client-sync backend # If you can use Docker without being root, you can `make SUDO= ` SUDO=sudo @@ -11,6 +11,7 @@ SCOPE_IMAGE=$(DOCKERHUB_USER)/scope SCOPE_EXPORT=scope.tar SCOPE_UI_BUILD_EXPORT=scope_ui_build.tar SCOPE_UI_BUILD_IMAGE=$(DOCKERHUB_USER)/scope-ui-build +SCOPE_BACKEND_BUILD_IMAGE=$(DOCKERHUB_USER)/scope-backend-build SCOPE_VERSION=$(shell git rev-parse --short HEAD) DOCKER_VERSION=1.3.1 DOCKER_DISTRIB=docker/docker-$(DOCKER_VERSION).tgz @@ -76,6 +77,11 @@ $(SCOPE_UI_BUILD_EXPORT): client/Dockerfile client/package.json client/webpack.l docker build -t $(SCOPE_UI_BUILD_IMAGE) client docker save $(SCOPE_UI_BUILD_IMAGE):latest > $@ +backend: + docker build -t $(SCOPE_BACKEND_BUILD_IMAGE) backend + docker run -ti -v $(shell pwd)/backend:/mount $(SCOPE_BACKEND_BUILD_IMAGE) cp /go/bin/scope-app /mount + docker run -ti -v $(shell pwd)/backend:/mount $(SCOPE_BACKEND_BUILD_IMAGE) cp /go/bin/scope-probe /mount + clean: go clean ./... rm -rf $(SCOPE_EXPORT) $(SCOPE_UI_BUILD_EXPORT) $(APP_EXE) $(PROBE_EXE) client/build/app.js diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 000000000..3d4fe97e7 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,5 @@ +FROM golang:1.5.1 +RUN apt-get update && apt-get install -y libpcap-dev +COPY build.bash / +RUN /build.bash + diff --git a/backend/build.bash b/backend/build.bash new file mode 100755 index 000000000..91c9f5d78 --- /dev/null +++ b/backend/build.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +mkdir -p /go/src/github.com/weaveworks +cd /go/src/github.com/weaveworks +git clone https://github.com/weaveworks/scope +cd scope +make deps +SUDO= make app/scope-app +mv app/scope-app $GOPATH/bin +SUDO= make probe/scope-probe +mv probe/scope-probe $GOPATH/bin + From dde214c10300f505091fc10e690f3c847a6e485d Mon Sep 17 00:00:00 2001 From: Peter Bourgon Date: Thu, 10 Sep 2015 15:43:19 +0200 Subject: [PATCH 2/3] Put the binaries in the official place --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4daa1611b..4372f3696 100644 --- a/Makefile +++ b/Makefile @@ -77,10 +77,11 @@ $(SCOPE_UI_BUILD_EXPORT): client/Dockerfile client/package.json client/webpack.l docker build -t $(SCOPE_UI_BUILD_IMAGE) client docker save $(SCOPE_UI_BUILD_IMAGE):latest > $@ +# backend is an alternate Docker-based method to produce APP_EXE and PROBE_EXE backend: docker build -t $(SCOPE_BACKEND_BUILD_IMAGE) backend - docker run -ti -v $(shell pwd)/backend:/mount $(SCOPE_BACKEND_BUILD_IMAGE) cp /go/bin/scope-app /mount - docker run -ti -v $(shell pwd)/backend:/mount $(SCOPE_BACKEND_BUILD_IMAGE) cp /go/bin/scope-probe /mount + docker run -ti -v $(shell pwd)/app:/mount $(SCOPE_BACKEND_BUILD_IMAGE) cp /go/bin/scope-app /mount + docker run -ti -v $(shell pwd)/probe:/mount $(SCOPE_BACKEND_BUILD_IMAGE) cp /go/bin/scope-probe /mount clean: go clean ./... From b97407a540ef0221255dec74b7d268f204b1fca8 Mon Sep 17 00:00:00 2001 From: Peter Bourgon Date: Thu, 10 Sep 2015 16:58:49 +0200 Subject: [PATCH 3/3] Use local checkout --- .gitignore | 2 -- Makefile | 4 +--- backend/Dockerfile | 1 - backend/build.bash | 18 +++++++++--------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index f76353492..b35e97f66 100644 --- a/.gitignore +++ b/.gitignore @@ -52,5 +52,3 @@ experimental/_integration/_integration *sublime-project *sublime-workspace *npm-debug.log -backend/scope-app -backend/scope-probe diff --git a/Makefile b/Makefile index 4372f3696..7106fb37c 100644 --- a/Makefile +++ b/Makefile @@ -77,11 +77,9 @@ $(SCOPE_UI_BUILD_EXPORT): client/Dockerfile client/package.json client/webpack.l docker build -t $(SCOPE_UI_BUILD_IMAGE) client docker save $(SCOPE_UI_BUILD_IMAGE):latest > $@ -# backend is an alternate Docker-based method to produce APP_EXE and PROBE_EXE backend: docker build -t $(SCOPE_BACKEND_BUILD_IMAGE) backend - docker run -ti -v $(shell pwd)/app:/mount $(SCOPE_BACKEND_BUILD_IMAGE) cp /go/bin/scope-app /mount - docker run -ti -v $(shell pwd)/probe:/mount $(SCOPE_BACKEND_BUILD_IMAGE) cp /go/bin/scope-probe /mount + docker run -ti -v $(shell pwd):/go/src/github.com/weaveworks/scope $(SCOPE_BACKEND_BUILD_IMAGE) /build.bash clean: go clean ./... diff --git a/backend/Dockerfile b/backend/Dockerfile index 3d4fe97e7..dc2716f1e 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,5 +1,4 @@ FROM golang:1.5.1 RUN apt-get update && apt-get install -y libpcap-dev COPY build.bash / -RUN /build.bash diff --git a/backend/build.bash b/backend/build.bash index 91c9f5d78..134cf557b 100755 --- a/backend/build.bash +++ b/backend/build.bash @@ -1,12 +1,12 @@ #!/bin/bash -mkdir -p /go/src/github.com/weaveworks -cd /go/src/github.com/weaveworks -git clone https://github.com/weaveworks/scope -cd scope -make deps -SUDO= make app/scope-app -mv app/scope-app $GOPATH/bin -SUDO= make probe/scope-probe -mv probe/scope-probe $GOPATH/bin +set -x + +# Mount the scope repo: +# -v $(pwd):/go/src/github.com/weaveworks/scope + +cd /go/src/github.com/weaveworks/scope +make deps +make app/scope-app +make probe/scope-probe