Skip to content

Commit

Permalink
Configure Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-paulau committed Jun 17, 2016
1 parent 719b131 commit c3cecf8
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 51 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM alpine:3.4

MAINTAINER Pavel Paulau <[email protected]>

EXPOSE 8000

ENV CB_HOST ""
ENV CB_PASS ""

COPY app app
COPY showfast /usr/local/bin/showfast

CMD ["showfast"]
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
build:
go build -v

fmt:
find . -name "*.go" -not -path "./vendor/*" | xargs gofmt -w -s

docker:
CGO_ENABLED=0 go build -v -a --ldflags "-s" && upx -q6 showfast
docker build --rm -t perflab/showfast .

clean:
rm -fr showfast
20 changes: 7 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/couchbaselabs/showfast)](https://goreportcard.com/report/github.com/couchbaselabs/showfast)

showfast
========
[![Go Report Card](https://goreportcard.com/badge/github.com/couchbaselabs/showfast)](https://goreportcard.com/report/github.com/couchbaselabs/showfast)

Performance dashboard. Powered by web.go, AngularJS, nvd3 and Couchbase Server.
Couchbase Server performance dashboard.

Prerequisites
-------------

* go 1.1
* Couchbase Server 2.0.0 or higher
* go 1.6
* Couchbase Server 4.x.

Required buckets
----------------

* benchmarks
* clusters
* feed
* metrics

Installation
------------

go get github.com/couchbaselabs/showfast

Usage
-----

$GOPATH/bin/showfast

All parameters are specified in config.json

docker pull perflab/showfast
docker run -t -i -e CB_HOST=... -e CB_PASS=... -p 8000:8000 perflab/showfast
5 changes: 0 additions & 5 deletions config.json

This file was deleted.

4 changes: 2 additions & 2 deletions datasources.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ var ddocs = map[string]string{
}

type DataSource struct {
CouchbaseAddress, BucketPassword string
hostname, password string
}

func (ds *DataSource) getBucket(bucket string) *couchbase.Bucket {
uri := fmt.Sprintf("http://%s:%s@%s/", bucket, ds.BucketPassword, ds.CouchbaseAddress)
uri := fmt.Sprintf("http://%s:%s@%s:8091/", bucket, ds.password, ds.hostname)

client, _ := couchbase.Connect(uri)
pool, _ := client.GetPool("default")
Expand Down
60 changes: 29 additions & 31 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,43 @@ import (
"github.com/hoisie/web"
)

var pkgDir string
const (
address = ":8000"
staticDir = "app"
)

var dataSource DataSource
var (
dataSource DataSource
cbHost, cbPass string
)

func home() []byte {
content, _ := ioutil.ReadFile(pkgDir + "app/index.html")
content, _ := ioutil.ReadFile("app/index.html")
return content
}

func allRuns(ctx *web.Context) []byte {
metric := ctx.Params["metric"]
build := ctx.Params["build"]

return dataSource.getAllRuns(metric, build)
}

func admin() []byte {
content, _ := ioutil.ReadFile(pkgDir + "app/admin.html")
content, _ := ioutil.ReadFile("app/admin.html")
return content
}

func release() []byte {
content, _ := ioutil.ReadFile(pkgDir + "app/release.html")
content, _ := ioutil.ReadFile("app/release.html")
return content
}

func feed() []byte {
content, _ := ioutil.ReadFile(pkgDir + "app/feed.html")
content, _ := ioutil.ReadFile("app/feed.html")
return content
}

func allRuns(ctx *web.Context) []byte {
metric := ctx.Params["metric"]
build := ctx.Params["build"]

return dataSource.getAllRuns(metric, build)
}

func getComparison(ctx *web.Context) []byte {
baseline := ctx.Params["baseline"]
target := ctx.Params["target"]
Expand All @@ -64,32 +70,24 @@ func reverseObsolete(ctx *web.Context) {
dataSource.reverseObsolete(params.ID)
}

type Config struct {
CouchbaseAddress, BucketPassword, ListenAddress string
func init() {
cbHost = os.Getenv("CB_HOST")
cbPass = os.Getenv("CB_PASS")
if cbHost == "" || cbPass == "" {
log.Fatalln("Missing Couchbase Server settings.")
}
}

func main() {
pkgDir = os.Getenv("GOPATH") + "/src/github.com/couchbaselabs/showfast/"
web.Config.StaticDir = pkgDir + "app"

configFile, err := ioutil.ReadFile(pkgDir + "config.json")
if err != nil {
log.Fatal(err)
}

var config Config
err = json.Unmarshal(configFile, &config)
if err != nil {
log.Fatal(err)
}

dataSource = DataSource{config.CouchbaseAddress, config.BucketPassword}
dataSource = DataSource{cbHost, cbPass}

web.Get("/", home)
web.Get("/admin", admin)
web.Get("/release", release)
web.Get("/feed", feed)

web.Config.StaticDir = staticDir

web.Get("/all_metrics", dataSource.getAllMetrics)
web.Get("/all_clusters", dataSource.getAllClusters)
web.Get("/all_timelines", dataSource.getAllTimelines)
Expand All @@ -101,5 +99,5 @@ func main() {
web.Post("/delete", deleteBenchmark)
web.Post("/reverse_obsolete", reverseObsolete)

web.Run(config.ListenAddress)
web.Run(address)
}

0 comments on commit c3cecf8

Please sign in to comment.