Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add standalone Dockerfile that runs agent, collector, and query #69

Merged
merged 24 commits into from
Apr 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ _site/
env/
Gemfile.lock
vendor/
examples/hotrod/hotrod
jaeger-ui-build/
examples/hotrod/hotrod*
cmd/standalone/standalone*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "idl"]
path = idl
url = https://github.com/uber/jaeger-idl.git
[submodule "jaeger-ui"]
path = jaeger-ui
url = https://github.com/uber/jaeger-ui
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,32 @@ go:
services:
- docker

env:
global:
- COMMIT=${TRAVIS_COMMIT::8}
# DOCKER_USER
- secure: TNvbr5/d7raSovEtttxdrZl8tP7vCCzL56gKKhr2wF4ET5/iRbcfSP9zoFPEOlIdgmCHZhGTh+fED1Eqgyswv6HPOAfEuov5vtzNB9fkcI46/nRk7KbiDlcEuE2IFtwkijFDz6YdJlbPCozHa81/Ih6G20H61tgv6f0AsGGT9MR7DQ71cCu8xZykNDjEKTo7RF6GiqG2VYa+S1P3vCOKRv31ouo/a5SPP+1AIvAg8u++qWVC8WJixmkXnw2OplvCFgHS0dlT3FvUPjYtUtLens5gpBDo7kn7+Ba27m2D0IzkzDPW5sK0YMMZW61LLn8GLPiJtLqzUHovaJ2NcFfi07RQ4GSMnwnjP0nLQbgd0CzM2zJGJRcOTkYe7IEDrdcTBcljZdZAJdoJEzrGYYWRQcX0Kyjc83ghX3A5s+CQWlPElQrkBB7KhNZ+w2Cn4+Mr6zOiRnBYg1NIUV2eGHMNnC4HI9RqgvA1QqcT5YHWqpz20sddHx1kgzgh8vOW8csiFon/Wrvyb2TaemzsKxIlT/UZZfDuyWG/Lvm4oxmTp1GrgQsC2iJjox4z6VIxbhykZEqNU1dhY6KuvgjEGetxk2j/NVfI8Qb4tvWqKoXq5Buap/J0AWjxWjGbrIGZbz5FgzfEP33WR8X2Oh5Cy+TMl1v0+YBAB3OaMpe/Qe2rGlk= # DOCKER_PASS
# DOCKER_PASS
- secure: mX3/Gwv5esCjU9GfqDaXbTslA0UOY9q45+rnW58X6z1tY2pFOts5uhtLve3YneGn3IN0n+m5mcljim72vKNQaPJCSodYfcfrqth2YqkYTXNWykOIdlLs1u58pYYGRXJaAlD4EgQysB/nAaQYO00/n2tBq4vEmu0dikbJer97smStkokLBiz42tJbvY6mikqnHHbRAA4dw5MHwYikDkI82oKxUsB8horetMmXgwTkT3AiE5UufXm3iYxpZ48KTYBW8WbQSQV1T1nriisZVErbYh69QLaLrEK3/WYiN3r4fOag4JvMA5GuPpuVGQfKzXUuFptG54VBbPKCgmcXA/DlaEQ6HILsfHdl29/AXHa59dVjWGfQ5f/N4VWaIVXhE0qWo+/WIoyr7SaLybyGVe3gf1vDaDFlfVlrE7j13H+XKiwzfOeaqnTrcNc/MSCFCtnUbjvX4UlXCbE4gVbCuEsjAPQ8mI/MMaCWLxhaYTW/cSyGRTGMLwe4Q8uAPd3BQat63byLo3BfK+icyw24RbSGBDRu5FZORK164MMjr0+UKVT3gh5/JdFxLkdOGjJL/9QuppNShI5GBIctIg15AQJNkhSLm8DxUTNHhjjBgXzqNhDVmUQLQVgqCWlHh1HVF5eiIQXBNGBE1Lw9v9dGTUHlPUUqeJKsxEyYWfZuY4tNhzU=

install:
- nvm version
- node -v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a minimum version, I would suggest nvm use 4 somewhere in this file - @saminzadeh thoughts?

- make install_ci

script:
- make test_ci
- travis_retry goveralls -coverprofile=cover.out -service=travis-ci || true

after_success:
- nvm use 4
- make build-all-in-one-linux || { echo 'failed build-all-in-one-linux' ; exit 0; }
- export REPO=jaegertracing/all-in-one
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
- export TAG=`if [ "$BRANCH" == "master" ]; then echo "latest"; else echo "${BRANCH///}"; fi`
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, REPO=$REPO, PR=$PR, BRANCH=$BRANCH, TAG=$TAG"
- docker login -u $DOCKER_USER -p $DOCKER_PASS
- docker build -f cmd/standalone/Dockerfile -t $REPO:$COMMIT .
- docker tag $REPO:$COMMIT $REPO:$TAG
- docker tag $REPO:$COMMIT $REPO:travis-$TRAVIS_BUILD_NUMBER
- docker push $REPO
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ install_examples: install
build_examples:
go build -o ./examples/hotrod/hotrod-demo ./examples/hotrod/main.go

build_ui:
cd jaeger-ui && npm install && npm run build
rm -rf jaeger-ui-build && mkdir jaeger-ui-build
cp -r jaeger-ui/build jaeger-ui-build/

build-all-in-one-linux: build_ui
CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./cmd/standalone/standalone-linux ./cmd/standalone/main.go

.PHONY: cover
cover:
./scripts/cover.sh $(shell go list $(PACKAGES))
Expand Down
2 changes: 2 additions & 0 deletions cmd/query/app/builder/builder_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ var (
QueryPort = flag.Int("query.port", 16686, "The port for the query service")
// QueryPrefix is the prefix of the query service api
QueryPrefix = flag.String("query.prefix", "api", "The prefix for the url of the query service")
// QueryStaticAssets is the path for the static assets for the UI (https://github.com/uber/jaeger-ui)
QueryStaticAssets = flag.String("query.static-files", "jaeger-ui-build/build/", "The path for the static assets for the UI")
)
5 changes: 5 additions & 0 deletions cmd/query/app/fixture/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Test Page</title>
</html>
23 changes: 14 additions & 9 deletions cmd/query/app/static_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,40 @@ import (
)

const (
staticAssetsRoot = "jaeger-ui-build/build/"
defaultStaticAssetsRoot = "jaeger-ui-build/build/"
)

var (
staticRootFiles = []string{"favicon.ico"}
)

// StaticAssetsHandler handles static assets
type StaticAssetsHandler struct{}
type StaticAssetsHandler struct {
staticAssetsRoot string
}

// NewStaticAssetsHandler returns a StaticAssetsHandler
func NewStaticAssetsHandler() *StaticAssetsHandler {
return &StaticAssetsHandler{}
func NewStaticAssetsHandler(staticAssetsRoot string) *StaticAssetsHandler {
if staticAssetsRoot == "" {
staticAssetsRoot = defaultStaticAssetsRoot
}
return &StaticAssetsHandler{staticAssetsRoot: staticAssetsRoot}
}

// RegisterRoutes registers routes for this handler on the given router
func (sH *StaticAssetsHandler) RegisterRoutes(router *mux.Router) {
router.PathPrefix("/static").Handler(http.FileServer(http.Dir(staticAssetsRoot)))
router.PathPrefix("/static").Handler(http.FileServer(http.Dir(sH.staticAssetsRoot)))
for _, file := range staticRootFiles {
router.Path("/" + file).HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, staticAssetsRoot+file)
http.ServeFile(w, r, sH.staticAssetsRoot+file)
})
}
router.NotFoundHandler = http.HandlerFunc(notFound)
router.NotFoundHandler = http.HandlerFunc(sH.notFound)
}

func notFound(w http.ResponseWriter, r *http.Request) {
func (sH *StaticAssetsHandler) notFound(w http.ResponseWriter, r *http.Request) {
// don't allow returning "304 Not Modified" for index.html because
// the cached versions might have the wrong filenames for javascript assets
delete(r.Header, "If-Modified-Since")
http.ServeFile(w, r, staticAssetsRoot+"index.html")
http.ServeFile(w, r, sH.staticAssetsRoot+"index.html")
}
9 changes: 7 additions & 2 deletions cmd/query/app/static_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

func TestStaticAssetsHandler(t *testing.T) {
r := mux.NewRouter()
handler := NewStaticAssetsHandler()
handler := NewStaticAssetsHandler("fixture/")
handler.RegisterRoutes(r)
server := httptest.NewServer(r)
defer server.Close()
Expand All @@ -44,5 +44,10 @@ func TestStaticAssetsHandler(t *testing.T) {
resp, err := httpClient.Get(server.URL)
assert.NoError(t, err)
defer resp.Body.Close()
assert.Equal(t, http.StatusNotFound, resp.StatusCode)
assert.Equal(t, http.StatusOK, resp.StatusCode)
}

func TestDefaultStaticAssetsRoot(t *testing.T) {
handler := NewStaticAssetsHandler("")
assert.Equal(t, "jaeger-ui-build/build/", handler.staticAssetsRoot)
}
2 changes: 1 addition & 1 deletion cmd/query/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func main() {
app.HandlerOptions.Adjusters(app.StandardAdjusters),
app.HandlerOptions.Prefix(*builder.QueryPrefix),
app.HandlerOptions.Logger(logger))
sHandler := app.NewStaticAssetsHandler()
sHandler := app.NewStaticAssetsHandler(*builder.QueryStaticAssets)
r := mux.NewRouter()
rHandler.RegisterRoutes(r)
sHandler.RegisterRoutes(r)
Expand Down
7 changes: 7 additions & 0 deletions cmd/standalone/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM golang:1.7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there may be a lighter base image than the one with full go tool chain (add TODO)

Copy link
Contributor

@vprithvi vprithvi Apr 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alpine image should work because we don't depend on git, etc
We can simply use golang:1.7-alpine

EXPOSE 5775 6831 6832 14267 16686

COPY ./jaeger-ui-build /go/src/jaeger-ui-build
COPY ./cmd/standalone/standalone-linux /go/bin/

ENTRYPOINT /go/bin/standalone-linux --span-storage.type=memory --query.static-files=/go/src/jaeger-ui-build/build/
2 changes: 1 addition & 1 deletion cmd/standalone/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func startQuery(logger *zap.Logger, baseFactory metrics.Factory, memoryStore *me
dependencyReader,
queryApp.HandlerOptions.Prefix(*query.QueryPrefix),
queryApp.HandlerOptions.Logger(logger))
sHandler := queryApp.NewStaticAssetsHandler()
sHandler := queryApp.NewStaticAssetsHandler(*query.QueryStaticAssets)
r := mux.NewRouter()
rHandler.RegisterRoutes(r)
sHandler.RegisterRoutes(r)
Expand Down
1 change: 1 addition & 0 deletions jaeger-ui
Submodule jaeger-ui added at 5f05a8