Permalink
Browse files

Create shared docker-compose and reuse it in crossdock (#493)

* Introduce shared docker-compose and reuse it in crossdock
* Fix empty static files
  • Loading branch information...
pavolloffay authored and yurishkuro committed Oct 30, 2017
1 parent 975982b commit 2acee35587a3d96aa885aa415a915dfeb8932c5a
View
@@ -20,6 +20,5 @@ cmd/collector/collector-linux
cmd/query/query
cmd/query/query-linux
cmd/query/jaeger-ui-build/
crossdock/crossdock
crossdock/.build/
crossdock/crossdock-linux
run-crossdock.log
View
@@ -31,7 +31,7 @@ THRIFT_GEN_DIR=thrift-gen
PASS=$(shell printf "\033[32mPASS\033[0m")
FAIL=$(shell printf "\033[31mFAIL\033[0m")
COLORIZE=$(SED) ''/PASS/s//$(PASS)/'' | $(SED) ''/FAIL/s//$(FAIL)/''
DOCKER_NAMESPACE?=$(USER)
DOCKER_NAMESPACE?=jaegertracing
DOCKER_TAG?=latest
.DEFAULT_GOAL := test-and-lint
@@ -116,8 +116,13 @@ build-query-linux:
build-collector-linux:
CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./cmd/collector/collector-linux ./cmd/collector/main.go
.PHONY: docker-no-ui
docker-no-ui: build-agent-linux build-collector-linux build-query-linux build-crossdock-linux
mkdir -p jaeger-ui-build/build/
make docker-images-only
.PHONY: docker
docker: build_ui build-agent-linux build-collector-linux build-query-linux docker-images-only
docker: build_ui docker-no-ui
.PHONY: docker-images-only
docker-images-only:
@@ -129,32 +134,33 @@ docker-images-only:
echo "Finished building $$component ==============" ; \
done
rm -rf cmd/query/jaeger-ui-build
docker build -t $(DOCKER_NAMESPACE)/test-driver:${DOCKER_TAG} crossdock/
@echo "Finished building test-driver ==============" ; \
.PHONY: docker-push
docker-push:
@while [ -z "$$CONFIRM" ]; do \
read -r -p "Do you really want to push images to repository \"${DOCKER_NAMESPACE}\"? [y/N] " CONFIRM; \
done ; \
if [ $$CONFIRM != "y" ] && [ $$CONFIRM != "Y" ]; then \
echo "Exiting." ; exit 1 ; \
fi
for component in agent cassandra-schema collector query ; do \
docker push $(DOCKER_NAMESPACE)/jaeger-$$component ; \
done
.PHONY: build-crossdock-linux
build-crossdock-linux:
CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./crossdock/crossdock ./crossdock/main.go
.PHONY: build-crossdock-bin
build-crossdock-bin:
make build-crossdock-linux
make build-query-linux
make build-collector-linux
make build-agent-linux
CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./crossdock/crossdock-linux ./crossdock/main.go
include crossdock/rules.mk
.PHONY: build-crossdock
build-crossdock: build-crossdock-bin
build-crossdock: docker-no-ui
make crossdock
.PHONY: build-crossdock-fresh
build-crossdock-fresh: build-crossdock-bin
build-crossdock-fresh: build-crossdock-linux
make crossdock-fresh
.PHONY: cover
@@ -27,10 +27,6 @@ import (
"github.com/pkg/errors"
)
const (
defaultStaticAssetsRoot = "jaeger-ui-build/build/"
)
var (
staticRootFiles = []string{"favicon.ico"}
configPattern = regexp.MustCompile("JAEGER_CONFIG *= *DEFAULT_CONFIG;")
@@ -45,7 +41,7 @@ type StaticAssetsHandler struct {
// NewStaticAssetsHandler returns a StaticAssetsHandler
func NewStaticAssetsHandler(staticAssetsRoot string, uiConfig string) (*StaticAssetsHandler, error) {
if staticAssetsRoot == "" {
staticAssetsRoot = defaultStaticAssetsRoot
return nil, nil
}
if !strings.HasSuffix(staticAssetsRoot, "/") {
staticAssetsRoot = staticAssetsRoot + "/"
@@ -47,8 +47,15 @@ func TestStaticAssetsHandler(t *testing.T) {
}
func TestDefaultStaticAssetsRoot(t *testing.T) {
_, err := NewStaticAssetsHandler("", "")
assert.EqualError(t, err, "Cannot read UI static assets: open jaeger-ui-build/build/index.html: no such file or directory")
handler, err := NewStaticAssetsHandler("", "")
assert.Nil(t, handler)
assert.Nil(t, err)
}
func TestNotExistingUiConfig(t *testing.T) {
handler, err := NewStaticAssetsHandler("/foo/bar", "")
assert.Equal(t, "Cannot read UI static assets: open /foo/bar/index.html: no such file or directory", err.Error())
assert.Nil(t, handler)
}
func TestRegisterRoutesHandler(t *testing.T) {
View
@@ -98,13 +98,9 @@ func main() {
app.HandlerOptions.Prefix(queryOpts.Prefix),
app.HandlerOptions.Logger(logger),
app.HandlerOptions.Tracer(tracer))
staticHandler, err := app.NewStaticAssetsHandler(queryOpts.StaticAssets, queryOpts.UIConfig)
if err != nil {
logger.Fatal("Could not create static assets handler", zap.Error(err))
}
r := mux.NewRouter()
apiHandler.RegisterRoutes(r)
staticHandler.RegisterRoutes(r)
registerStaticHandler(r, logger, queryOpts)
portStr := ":" + strconv.Itoa(queryOpts.Port)
recoveryHandler := recoveryhandler.NewRecoveryHandler(logger, true)
@@ -139,3 +135,15 @@ func main() {
logger.Fatal(error.Error())
}
}
func registerStaticHandler(r *mux.Router, logger *zap.Logger, qOpts *builder.QueryOptions) {
staticHandler, err := app.NewStaticAssetsHandler(qOpts.StaticAssets, qOpts.UIConfig)
if err != nil {
logger.Fatal("Could not create static assets handler", zap.Error(err))
}
if staticHandler != nil {
staticHandler.RegisterRoutes(r)
} else {
logger.Info("Static handler is not registered")
}
}
View
@@ -221,17 +221,25 @@ func startQuery(
queryApp.HandlerOptions.Prefix(qOpts.Prefix),
queryApp.HandlerOptions.Logger(logger),
queryApp.HandlerOptions.Tracer(tracer))
staticHandler, err := queryApp.NewStaticAssetsHandler(qOpts.StaticAssets, qOpts.UIConfig)
if err != nil {
logger.Fatal("Could not create static assets handler", zap.Error(err))
}
r := mux.NewRouter()
apiHandler.RegisterRoutes(r)
staticHandler.RegisterRoutes(r)
registerStaticHandler(r, logger, qOpts)
portStr := ":" + strconv.Itoa(qOpts.Port)
recoveryHandler := recoveryhandler.NewRecoveryHandler(logger, true)
logger.Info("Starting jaeger-query HTTP server", zap.Int("port", qOpts.Port))
if err := http.ListenAndServe(portStr, recoveryHandler(r)); err != nil {
logger.Fatal("Could not launch jaeger-query service", zap.Error(err))
}
}
func registerStaticHandler(r *mux.Router, logger *zap.Logger, qOpts *query.QueryOptions) {
staticHandler, err := queryApp.NewStaticAssetsHandler(qOpts.StaticAssets, qOpts.UIConfig)
if err != nil {
logger.Fatal("Could not create static assets handler", zap.Error(err))
}
if staticHandler != nil {
staticHandler.RegisterRoutes(r)
} else {
logger.Info("Static handler is not registered")
}
}
View
@@ -1,8 +1,6 @@
FROM gliderlabs/alpine
ADD crossdock /
CMD ["/crossdock"]
EXPOSE 8080
FROM scratch
COPY crossdock-linux /go/bin/
COPY .build/scripts/* /scripts/
COPY .build/cmd/* /cmd/
COPY .build/ui/* /ui/
EXPOSE 8080
CMD ["/go/bin/crossdock-linux"]
@@ -4,6 +4,9 @@ services:
crossdock:
image: crossdock/crossdock
links:
- jaeger-query
- jaeger-collector
- jaeger-agent
- test_driver
- go
- node
@@ -27,48 +30,54 @@ services:
image: jaegertracing/xdock-go
ports:
- "8080-8082"
links:
- "jaeger-agent:test_driver"
node:
image: jaegertracing/xdock-node
ports:
- "8080-8082"
links:
- "jaeger-agent:test_driver"
java:
image: jaegertracing/xdock-java
ports:
- "8080-8082"
depends_on:
- test_driver
links:
- "jaeger-agent:test_driver"
python:
image: jaegertracing/xdock-py
ports:
- "8080-8082"
links:
- "jaeger-agent:test_driver"
zipkin-brave-json:
image: jaegertracing/xdock-zipkin-brave
ports:
- "8080-8081"
environment:
- ENCODING=JSON
links:
- "jaeger-collector:test_driver"
zipkin-brave-thrift:
image: jaegertracing/xdock-zipkin-brave
ports:
- "8080-8081"
environment:
- ENCODING=THRIFT
cassandra:
image: "cassandra:3.9"
links:
- "jaeger-collector:test_driver"
test_driver:
build: .
image: jaegertracing/test-driver:latest
links:
- cassandra
depends_on:
- cassandra
image: jaegertracing/test-driver
ports:
- "8080"
jaeger-query:
# override to disable static files
command: ["/go/bin/query-linux", "--query.static-files=", "--cassandra.keyspace=jaeger_v1_dc1", "--cassandra.servers=cassandra"]
Oops, something went wrong.

0 comments on commit 2acee35

Please sign in to comment.