mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
Add flag to allow using external ui, and ability to upload to bucket during CI
This commit is contained in:
13
Makefile
13
Makefile
@@ -1,4 +1,4 @@
|
||||
.PHONY: all deps static clean client-lint client-test client-sync backend frontend shell lint
|
||||
.PHONY: all deps static clean client-lint client-test client-sync backend frontend shell lint ui-upload
|
||||
|
||||
# If you can use Docker without being root, you can `make SUDO= <target>`
|
||||
SUDO=$(shell docker info >/dev/null 2>&1 || echo "sudo -E")
|
||||
@@ -126,7 +126,7 @@ client/build/index.html: $(shell find client/app -type f) $(SCOPE_UI_BUILD_UPTOD
|
||||
client/build-external/index.html: $(shell find client/app -type f) $(SCOPE_UI_BUILD_UPTODATE)
|
||||
mkdir -p client/build
|
||||
$(SUDO) docker run $(RM) $(RUN_FLAGS) -v $(shell pwd)/client/app:/home/weave/app \
|
||||
-v $(shell pwd)/client/build:/home/weave/build \
|
||||
-v $(shell pwd)/client/build-external:/home/weave/build-external \
|
||||
$(SCOPE_UI_BUILD_IMAGE) npm run build-external
|
||||
|
||||
client-test: $(shell find client/app/scripts -type f) $(SCOPE_UI_BUILD_UPTODATE)
|
||||
@@ -154,7 +154,7 @@ client/build-external/index.html:
|
||||
|
||||
endif
|
||||
|
||||
$(SCOPE_UI_BUILD_UPTODATE): client/Dockerfile client/package.json client/webpack.local.config.js client/webpack.production.config.js client/server.js client/.eslintrc
|
||||
$(SCOPE_UI_BUILD_UPTODATE): client/Dockerfile client/package.json client/webpack.local.config.js client/webpack.production.config.js client/webpack.external.config.js client/server.js client/.eslintrc
|
||||
$(SUDO) docker build -t $(SCOPE_UI_BUILD_IMAGE) client
|
||||
touch $@
|
||||
|
||||
@@ -162,13 +162,18 @@ $(SCOPE_BACKEND_BUILD_UPTODATE): backend/*
|
||||
$(SUDO) docker build -t $(SCOPE_BACKEND_BUILD_IMAGE) backend
|
||||
touch $@
|
||||
|
||||
ui-upload: client/build-external/index.html
|
||||
AWS_ACCESS_KEY_ID=$$UI_BUCKET_KEY_ID \
|
||||
AWS_SECRET_ACCESS_KEY=$$UI_BUCKET_KEY_SECRET \
|
||||
aws s3 cp client/build-external/ s3://static.weave.works/scope-ui/ --recursive --exclude '*.html'
|
||||
|
||||
clean:
|
||||
$(GO) clean ./...
|
||||
# Don't actually rmi the build images - rm'ing the .uptodate files is enough to ensure
|
||||
# we rebuild the images, and rmi'ing the images causes us to have to redownload a lot of stuff.
|
||||
# $(SUDO) docker rmi $(SCOPE_UI_BUILD_IMAGE) $(SCOPE_BACKEND_BUILD_IMAGE) >/dev/null 2>&1 || true
|
||||
rm -rf $(SCOPE_EXPORT) $(SCOPE_UI_BUILD_UPTODATE) $(SCOPE_BACKEND_BUILD_UPTODATE) \
|
||||
$(SCOPE_EXE) $(RUNSVINIT) prog/static.go client/build/*.js docker/weave .pkg \
|
||||
$(SCOPE_EXE) $(RUNSVINIT) prog/staticui/staticui.go prog/externalui/externalui.go client/build/*.js client/build-external/*.js docker/weave .pkg \
|
||||
$(CODECGEN_TARGETS) $(CODECGEN_DIR)/bin
|
||||
|
||||
clean-codecgen:
|
||||
|
||||
@@ -30,7 +30,7 @@ dependencies:
|
||||
- "cd $SRCDIR/backend; ../tools/rebuild-image weaveworks/scope-backend-build . Dockerfile build.sh && touch $SRCDIR/.scope_backend_build.uptodate"
|
||||
- test -z "$SECRET_PASSWORD" || (cd $SRCDIR/integration; ./gce.sh make_template):
|
||||
parallel: false
|
||||
- sudo apt-get update && sudo apt-get install python-pip && sudo pip install awscli:
|
||||
- sudo apt-get update && sudo apt-get install python-pip && sudo pip install awscli
|
||||
|
||||
test:
|
||||
override:
|
||||
@@ -80,6 +80,9 @@ deployment:
|
||||
docker push ${DOCKER_ORGANIZATION:-$DOCKER_USER}/scope:$(./tools/image-tag) &&
|
||||
docker push ${DOCKER_ORGANIZATION:-$DOCKER_USER}/scope-traffic-control-plugin &&
|
||||
docker push ${DOCKER_ORGANIZATION:-$DOCKER_USER}/scope-traffic-control-plugin:$(./tools/image-tag) &&
|
||||
(test -n "${UI_BUCKET_KEY_ID}" || (
|
||||
make ui-upload
|
||||
)) &&
|
||||
(test "${DOCKER_ORGANIZATION:-$DOCKER_USER}" != "weaveworks" || (
|
||||
wcloud deploy -u circle weaveworks/scope:$(./tools/image-tag)
|
||||
))
|
||||
|
||||
@@ -36,7 +36,7 @@ module.exports = {
|
||||
path: path.join(__dirname, 'build-external/'),
|
||||
filename: '[name]-[chunkhash].js',
|
||||
// Change this line to point to resources on an external host.
|
||||
publicPath: 'https://s3.amazonaws.com/static.weave.works/service-ui/'
|
||||
publicPath: 'https://s3.amazonaws.com/static.weave.works/scope-ui/'
|
||||
},
|
||||
|
||||
module: {
|
||||
|
||||
@@ -47,7 +47,7 @@ func init() {
|
||||
}
|
||||
|
||||
// Router creates the mux for all the various app components.
|
||||
func router(collector app.Collector, controlRouter app.ControlRouter, pipeRouter app.PipeRouter) http.Handler {
|
||||
func router(collector app.Collector, controlRouter app.ControlRouter, pipeRouter app.PipeRouter, externalUI bool) http.Handler {
|
||||
router := mux.NewRouter().SkipClean(true)
|
||||
|
||||
// We pull in the http.DefaultServeMux to get the pprof routes
|
||||
@@ -59,7 +59,7 @@ func router(collector app.Collector, controlRouter app.ControlRouter, pipeRouter
|
||||
app.RegisterPipeRoutes(router, pipeRouter)
|
||||
app.RegisterTopologyRoutes(router, collector)
|
||||
|
||||
uiHandler := http.FileServer(GetFS(false))
|
||||
uiHandler := http.FileServer(GetFS(externalUI))
|
||||
router.PathPrefix("/ui").Name("static").Handler(
|
||||
middleware.PathRewrite(regexp.MustCompile("^/ui"), "").Wrap(
|
||||
uiHandler))
|
||||
@@ -267,7 +267,7 @@ func appMain(flags appFlags) {
|
||||
}
|
||||
}
|
||||
|
||||
handler := router(collector, controlRouter, pipeRouter)
|
||||
handler := router(collector, controlRouter, pipeRouter, flags.externalUI)
|
||||
if flags.logHTTP {
|
||||
handler = middleware.Logging.Wrap(handler)
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ type appFlags struct {
|
||||
memcachedExpiration time.Duration
|
||||
memcachedCompressionLevel int
|
||||
userIDHeader string
|
||||
externalUI bool
|
||||
|
||||
blockProfileRate int
|
||||
|
||||
@@ -255,6 +256,7 @@ func main() {
|
||||
flag.StringVar(&flags.app.memcachedService, "app.memcached.service", "memcached", "SRV service used to discover memcache servers.")
|
||||
flag.IntVar(&flags.app.memcachedCompressionLevel, "app.memcached.compression", gzip.DefaultCompression, "How much to compress reports stored in memcached.")
|
||||
flag.StringVar(&flags.app.userIDHeader, "app.userid.header", "", "HTTP header to use as userid")
|
||||
flag.BoolVar(&flags.app.externalUI, "app.externalUI", false, "Point to externally hosted static UI assets")
|
||||
|
||||
flag.IntVar(&flags.app.blockProfileRate, "app.block.profile.rate", 0, "If more than 0, enable block profiling. The profiler aims to sample an average of one blocking event per rate nanoseconds spent blocked.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user