Description: Avoid embedding blobs into the prometheus binary, instead use
 files installed on disk.
--- a/web/web.go
+++ b/web/web.go
@@ -14,7 +14,6 @@
 package web
 
 import (
-	"bytes"
 	"context"
 	"encoding/json"
 	"fmt"
@@ -62,7 +61,6 @@
 	"github.com/prometheus/prometheus/util/httputil"
 	api_v1 "github.com/prometheus/prometheus/web/api/v1"
 	api_v2 "github.com/prometheus/prometheus/web/api/v2"
-	"github.com/prometheus/prometheus/web/ui"
 )
 
 var localhostRepresentations = []string{"127.0.0.1", "localhost"}
@@ -137,7 +135,7 @@
 	ExternalURL          *url.URL
 	RoutePrefix          string
 	MetricsPath          string
-	UseLocalAssets       bool
+	LocalAssets          string
 	UserAssetsPath       string
 	ConsoleTemplatesPath string
 	ConsoleLibrariesPath string
@@ -228,7 +226,7 @@
 
 	router.Get("/consoles/*filepath", readyf(instrf("consoles", h.consoles)))
 
-	router.Get("/static/*filepath", instrf("static", h.serveStaticAsset))
+	router.Get("/static/*filepath", instrf("user", route.FileServe(filepath.Join(o.LocalAssets, "/static"))))
 
 	if o.UserAssetsPath != "" {
 		router.Get("/user/*filepath", instrf("user", route.FileServe(o.UserAssetsPath)))
@@ -315,28 +313,6 @@
 	}
 }
 
-func (h *Handler) serveStaticAsset(w http.ResponseWriter, req *http.Request) {
-	fp := route.Param(req.Context(), "filepath")
-	fp = filepath.Join("web/ui/static", fp)
-
-	info, err := ui.AssetInfo(fp)
-	if err != nil {
-		level.Warn(h.logger).Log("msg", "Could not get file info", "err", err, "file", fp)
-		w.WriteHeader(http.StatusNotFound)
-		return
-	}
-	file, err := ui.Asset(fp)
-	if err != nil {
-		if err != io.EOF {
-			level.Warn(h.logger).Log("msg", "Could not get file", "err", err, "file", fp)
-		}
-		w.WriteHeader(http.StatusNotFound)
-		return
-	}
-
-	http.ServeContent(w, req, info.Name(), info.ModTime(), bytes.NewReader(file))
-}
-
 // Ready sets Handler to be ready.
 func (h *Handler) Ready() {
 	atomic.StoreUint32(&h.ready, 1)
@@ -743,11 +719,11 @@
 }
 
 func (h *Handler) getTemplate(name string) (string, error) {
-	baseTmpl, err := ui.Asset("web/ui/templates/_base.html")
+	baseTmpl, err := ioutil.ReadFile(filepath.Join(h.options.LocalAssets, "templates/_base.html"))
 	if err != nil {
 		return "", fmt.Errorf("error reading base template: %s", err)
 	}
-	pageTmpl, err := ui.Asset(filepath.Join("web/ui/templates", name))
+	pageTmpl, err := ioutil.ReadFile(filepath.Join(h.options.LocalAssets, "templates", name))
 	if err != nil {
 		return "", fmt.Errorf("error reading page template %s: %s", name, err)
 	}
--- a/console_libraries/prom.lib
+++ b/console_libraries/prom.lib
@@ -1,14 +1,13 @@
 {{/* vim: set ft=html: */}}
 {{/* Load Prometheus console library JS/CSS. Should go in <head> */}}
 {{ define "prom_console_head" }}
-<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.css">
-<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/css/bootstrap.min.css">
+<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/rickshaw/rickshaw.min.css">
+<link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/bootstrap/css/bootstrap.min.css">
 <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/prom_console.css">
-<script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.v3.js"></script>
-<script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.layout.min.js"></script>
-<script src="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.js"></script>
-<script src="{{ pathPrefix }}/static/vendor/js/jquery.min.js"></script>
-<script src="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js"></script>
+<script src="{{ pathPrefix }}/static/d3/d3.js"></script>
+<script src="{{ pathPrefix }}/static/rickshaw/rickshaw.min.js"></script>
+<script src="{{ pathPrefix }}/static/jquery/jquery.min.js"></script>
+<script src="{{ pathPrefix }}/static/bootstrap/js/bootstrap.min.js"></script>
 
 <script>
 var PATH_PREFIX = "{{ pathPrefix }}";
--- a/web/ui/templates/_base.html
+++ b/web/ui/templates/_base.html
@@ -4,10 +4,10 @@
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     <title>Prometheus Time Series Collection and Processing Server</title>
     <link rel="shortcut icon" href="{{ pathPrefix }}/static/img/favicon.ico?v={{ buildVersion }}">
-    <script src="{{ pathPrefix }}/static/vendor/js/jquery.min.js?v={{ buildVersion }}"></script>
-    <script src="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js?v={{ buildVersion }}"></script>
+    <script src="{{ pathPrefix }}/static/jquery/jquery.min.js?v={{ buildVersion }}"></script>
+    <script src="{{ pathPrefix }}/static/bootstrap/js/bootstrap.min.js?v={{ buildVersion }}"></script>
 
-    <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/bootstrap-3.3.1/css/bootstrap.min.css?v={{ buildVersion }}">
+    <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/bootstrap/css/bootstrap.min.css?v={{ buildVersion }}">
     <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/prometheus.css?v={{ buildVersion }}">
 
     <script>
--- a/cmd/prometheus/main.go
+++ b/cmd/prometheus/main.go
@@ -134,6 +134,9 @@
 		"Prefix for the internal routes of web endpoints. Defaults to path of --web.external-url.").
 		PlaceHolder("<path>").StringVar(&cfg.web.RoutePrefix)
 
+	a.Flag("web.local-assets", "Path to static asset/templates directory.").
+		Default("/usr/share/prometheus/web/").StringVar(&cfg.web.LocalAssets)
+
 	a.Flag("web.user-assets", "Path to static asset directory, available at /user.").
 		PlaceHolder("<path>").StringVar(&cfg.web.UserAssetsPath)
 
--- a/web/ui/templates/graph.html
+++ b/web/ui/templates/graph.html
@@ -1,21 +1,20 @@
 {{define "head"}}
     <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/css/graph.css?v={{ buildVersion }}">
 
-    <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.css?v={{ buildVersion }}">
-    <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.css?v={{ buildVersion }}">
+    <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/rickshaw/rickshaw.min.css?v={{ buildVersion }}">
+    <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.css?v={{ buildVersion }}">
 
-    <script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.v3.js?v={{ buildVersion }}"></script>
-    <script src="{{ pathPrefix }}/static/vendor/rickshaw/vendor/d3.layout.min.js?v={{ buildVersion }}"></script>
-    <script src="{{ pathPrefix }}/static/vendor/rickshaw/rickshaw.min.js?v={{ buildVersion }}"></script>
-    <script src="{{ pathPrefix }}/static/vendor/moment/moment.min.js?v={{ buildVersion }}"></script>
+    <script src="{{ pathPrefix }}/static/d3/d3.min.js?v={{ buildVersion }}"></script>
+    <script src="{{ pathPrefix }}/static/rickshaw/rickshaw.min.js?v={{ buildVersion }}"></script>
+    <script src="{{ pathPrefix }}/static/moment/moment.min.js?v={{ buildVersion }}"></script>
     <script src="{{ pathPrefix }}/static/vendor/moment/moment-timezone-with-data.min.js?v={{ buildVersion }}"></script>
-    <script src="{{ pathPrefix }}/static/vendor/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.js?v={{ buildVersion }}"></script>
-    <script src="{{ pathPrefix }}/static/vendor/bootstrap3-typeahead/bootstrap3-typeahead.min.js?v={{ buildVersion }}"></script>
+    <script src="{{ pathPrefix }}/static/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.js?v={{ buildVersion }}"></script>
+    <script src="{{ pathPrefix }}/static/vendor/bootstrap3-typeahead/bootstrap3-typeahead.js?v={{ buildVersion }}"></script>
     <script src="{{ pathPrefix }}/static/vendor/fuzzy/fuzzy.js?v={{ buildVersion }}"></script>
 
-    <script src="{{ pathPrefix }}/static/vendor/mustache/mustache.min.js?v={{ buildVersion }}"></script>
+    <script src="{{ pathPrefix }}/static/mustache/mustache.min.js?v={{ buildVersion }}"></script>
     <script src="{{ pathPrefix }}/static/vendor/js/jquery.selection.js?v={{ buildVersion }}"></script>
-    <script src="{{ pathPrefix }}/static/vendor/js/jquery.hotkeys.js?v={{ buildVersion }}"></script>
+    <script src="{{ pathPrefix }}/static/jquery-hotkeys/jquery.hotkeys.js?v={{ buildVersion }}"></script>
 
     <script src="{{ pathPrefix }}/static/js/graph/index.js?v={{ buildVersion }}"></script>
 
