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

docker-compose and reuse it in crossdock #493

Merged
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: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 18 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

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

Setting the repository to the correct one. I added user input to docker push to avoid unwanted pushes.

Copy link
Contributor

Choose a reason for hiding this comment

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

This was on purpose, so that we don't push accidentally to the official repository. Just pass DOCKER_NAMESPACE before the make command to override it:

DOCKER_NAMESPACE=jaegertracing make

Or, like this:

export DOCKER_NAMESPACE=jaegertracing

Copy link
Member Author

Choose a reason for hiding this comment

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

This was on purpose, so that we don't push accidentally to the official repository.

I know, because of this I have added user input/verification before docker push.

This change is because now xdock uses only docker images so it has to build. We could use different image names/repository in docker-compose but that seems more odd.

Copy link
Member Author

Choose a reason for hiding this comment

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

This should work CONTINUE=y make docker-push

DOCKER_TAG?=latest

.DEFAULT_GOAL := test-and-lint
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
6 changes: 1 addition & 5 deletions cmd/query/app/static_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;")
Expand All @@ -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 + "/"
Expand Down
11 changes: 9 additions & 2 deletions cmd/query/app/static_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 13 additions & 5 deletions cmd/query/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")
}
}
18 changes: 13 additions & 5 deletions cmd/standalone/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
12 changes: 5 additions & 7 deletions crossdock/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
33 changes: 21 additions & 12 deletions crossdock/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ services:
crossdock:
image: crossdock/crossdock
links:
- jaeger-query
- jaeger-collector
- jaeger-agent
- test_driver
- go
- node
Expand All @@ -27,48 +30,54 @@ services:
image: jaegertracing/xdock-go
ports:
- "8080-8082"
links:
- "jaeger-agent:test_driver"
Copy link
Member Author

Choose a reason for hiding this comment

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

Temporary fix, xdock images expect jaeger services on this host.


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"]

Loading