diff --git a/.travis.yml b/.travis.yml index c3f0bb9818b..ffddbc460a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,7 +67,7 @@ script: - export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi) - if [ "$TESTS" == true ]; then make test-ci ; else echo 'skipping tests'; fi - if [ "$PROTO_GEN_TEST" == true ]; then make proto && git diff --name-status --exit-code ; else echo 'skipping protoc validation'; fi - - if [ "$ALL_IN_ONE" == true ]; then bash ./scripts/travis/build-all-in-one-image.sh ; else echo 'skipping all_in_one'; fi + - if [ "$ALL_IN_ONE" == true ]; then make create-baseimg-debugimg && bash ./scripts/travis/build-all-in-one-image.sh ; else echo 'skipping all_in_one'; fi - if [ "$CROSSDOCK" == true ]; then travis_retry bash ./scripts/travis/build-crossdock.sh ; else echo 'skipping crossdock'; fi - if [ "$CROSSDOCK_OTEL" == true ]; then travis_retry make build-crossdock crossdock-otel ; else echo 'skipping OpenTelemetry crossdock'; fi - if [ "$DOCKER" == true ]; then bash ./scripts/travis/build-docker-images.sh ; else echo 'skipping build-docker-images'; fi diff --git a/Makefile b/Makefile index 18317a93ff2..1b1c42b1c89 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,8 @@ JAEGER_IMPORT_PATH=github.com/jaegertracing/jaeger STORAGE_PKGS = ./plugin/storage/integration/... OTEL_COLLECTOR_DIR = ./cmd/opentelemetry +include docker/Makefile + # all .go files that are not auto-generated and should be auto-formatted and linted. ALL_SRC := $(shell find . -name '*.go' \ -not -name 'doc.go' \ @@ -243,21 +245,24 @@ cmd/query/app/ui/placeholder/gen_assets.go: cmd/query/app/ui/placeholder/public/ build-all-in-one-linux: GOOS=linux $(MAKE) build-all-in-one -.PHONY: build-all-in-one -build-all-in-one: build-ui elasticsearch-mappings - $(GOBUILD) -tags ui -o ./cmd/all-in-one/all-in-one-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/all-in-one/main.go +build-all-in-one-debug build-agent-debug build-query-debug build-collector-debug build-ingester-debug: DISABLE_OPTIMIZATIONS = -gcflags="all=-N -l" +build-all-in-one-debug build-agent-debug build-query-debug build-collector-debug build-ingester-debug: SUFFIX = -debug + +.PHONY: build-all-in-one build-all-in-one-debug +build-all-in-one build-all-in-one-debug: build-ui elasticsearch-mappings + $(GOBUILD) $(DISABLE_OPTIMIZATIONS) -tags ui -o ./cmd/all-in-one/all-in-one$(SUFFIX)-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/all-in-one/main.go -.PHONY: build-agent -build-agent: - $(GOBUILD) -o ./cmd/agent/agent-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/agent/main.go +.PHONY: build-agent build-agent-debug +build-agent build-agent-debug: + $(GOBUILD) $(DISABLE_OPTIMIZATIONS) -o ./cmd/agent/agent$(SUFFIX)-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/agent/main.go -.PHONY: build-query -build-query: build-ui - $(GOBUILD) -tags ui -o ./cmd/query/query-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/query/main.go +.PHONY: build-query build-query-debug +build-query build-query-debug: build-ui + $(GOBUILD) $(DISABLE_OPTIMIZATIONS) -tags ui -o ./cmd/query/query$(SUFFIX)-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/query/main.go -.PHONY: build-collector -build-collector: elasticsearch-mappings - $(GOBUILD) -o ./cmd/collector/collector-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/collector/main.go +.PHONY: build-collector build-collector-debug +build-collector build-collector-debug: elasticsearch-mappings + $(GOBUILD) $(DISABLE_OPTIMIZATIONS) -o ./cmd/collector/collector$(SUFFIX)-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/collector/main.go .PHONY: build-otel-collector build-otel-collector: elasticsearch-mappings @@ -275,9 +280,9 @@ build-otel-ingester: build-otel-all-in-one: build-ui cd ${OTEL_COLLECTOR_DIR}/cmd/all-in-one && $(GOBUILD) -tags ui -o ./opentelemetry-all-in-one-$(GOOS)-$(GOARCH) $(BUILD_INFO) main.go -.PHONY: build-ingester -build-ingester: - $(GOBUILD) -o ./cmd/ingester/ingester-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/ingester/main.go +.PHONY: build-ingester build-ingester-debug +build-ingester build-ingester-debug: + $(GOBUILD) $(DISABLE_OPTIMIZATIONS) -o ./cmd/ingester/ingester$(SUFFIX)-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/ingester/main.go .PHONY: docker docker: build-binaries-linux docker-images-only @@ -307,7 +312,21 @@ build-binaries-ppc64le: GOOS=linux GOARCH=ppc64le $(MAKE) build-platform-binaries .PHONY: build-platform-binaries -build-platform-binaries: build-agent build-collector build-query build-ingester build-all-in-one build-examples build-tracegen build-otel-collector build-otel-agent build-otel-ingester build-otel-all-in-one +build-platform-binaries: build-agent \ + build-agent-debug \ + build-collector \ + build-collector-debug \ + build-query \ + build-query-debug \ + build-ingester \ + build-ingester-debug \ + build-all-in-one \ + build-examples \ + build-tracegen \ + build-otel-collector \ + build-otel-agent \ + build-otel-ingester \ + build-otel-all-in-one .PHONY: build-all-platforms build-all-platforms: build-binaries-linux build-binaries-windows build-binaries-darwin build-binaries-s390x build-binaries-arm64 build-binaries-ppc64le @@ -323,10 +342,19 @@ docker-images-elastic: docker build -t $(DOCKER_NAMESPACE)/jaeger-es-rollover:${DOCKER_TAG} plugin/storage/es -f plugin/storage/es/Dockerfile.rollover @echo "Finished building jaeger-es-indices-clean ==============" -.PHONY: docker-images-jaeger-backend -docker-images-jaeger-backend: +docker-images-jaeger-backend: TARGET = release +docker-images-jaeger-backend-debug: TARGET = debug +docker-images-jaeger-backend-debug: SUFFIX = -debug + +.PHONY: docker-images-jaeger-backend docker-images-jaeger-backend-debug +docker-images-jaeger-backend docker-images-jaeger-backend-debug: create-baseimg create-debugimg for component in agent collector query ingester ; do \ - docker build -t $(DOCKER_NAMESPACE)/jaeger-$$component:${DOCKER_TAG} cmd/$$component --build-arg TARGETARCH=$(GOARCH) ; \ + docker build --target $(TARGET) \ + --tag $(DOCKER_NAMESPACE)/jaeger-$$component$(SUFFIX):${DOCKER_TAG} \ + --build-arg base_image=$(BASE_IMAGE) \ + --build-arg debug_image=$(DEBUG_IMAGE) \ + --build-arg TARGETARCH=$(GOARCH) \ + cmd/$$component ; \ echo "Finished building $$component ==============" ; \ done docker build -t $(DOCKER_NAMESPACE)/jaeger-opentelemetry-collector:${DOCKER_TAG} -f ${OTEL_COLLECTOR_DIR}/cmd/collector/Dockerfile cmd/opentelemetry/cmd/collector --build-arg TARGETARCH=$(GOARCH) @@ -339,7 +367,11 @@ docker-images-tracegen: @echo "Finished building jaeger-tracegen ==============" .PHONY: docker-images-only -docker-images-only: docker-images-cassandra docker-images-elastic docker-images-jaeger-backend docker-images-tracegen +docker-images-only: docker-images-cassandra \ + docker-images-elastic \ + docker-images-jaeger-backend \ + docker-images-jaeger-backend-debug \ + docker-images-tracegen .PHONY: docker-push docker-push: diff --git a/cmd/agent/Dockerfile b/cmd/agent/Dockerfile index 10e450d1768..2c7ee6f1d51 100644 --- a/cmd/agent/Dockerfile +++ b/cmd/agent/Dockerfile @@ -1,13 +1,18 @@ -FROM alpine:latest as certs -RUN apk add --update --no-cache ca-certificates +ARG base_image +ARG debug_image -FROM scratch +FROM $base_image AS release ARG TARGETARCH=amd64 ARG USER_UID=10001 -COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt - -EXPOSE 5775/udp 6831/udp 6832/udp 5778 COPY agent-linux-$TARGETARCH /go/bin/agent-linux +EXPOSE 5775/udp 6831/udp 6832/udp 5778/tcp ENTRYPOINT ["/go/bin/agent-linux"] +USER ${USER_UID} +FROM $debug_image AS debug +ARG TARGETARCH=amd64 +ARG USER_UID=10001 +COPY agent-debug-linux-$TARGETARCH /go/bin/agent-linux +EXPOSE 5775/udp 6831/udp 6832/udp 5778/tcp 12345/tcp +ENTRYPOINT ["/go/bin/dlv", "exec", "/go/bin/agent-linux", "--headless", "--listen=:12345", "--api-version=2", "--accept-multiclient", "--log", "--"] USER ${USER_UID} diff --git a/cmd/all-in-one/Dockerfile b/cmd/all-in-one/Dockerfile index 8652f2decbe..2c7589f95d7 100644 --- a/cmd/all-in-one/Dockerfile +++ b/cmd/all-in-one/Dockerfile @@ -1,11 +1,9 @@ -FROM alpine:latest as certs -RUN apk add --update --no-cache ca-certificates +ARG base_image +ARG debug_image -FROM scratch +FROM $base_image AS release ARG TARGETARCH=amd64 -COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt - # Agent zipkin.thrift compact EXPOSE 5775/udp @@ -33,3 +31,37 @@ COPY sampling_strategies.json /etc/jaeger/ VOLUME ["/tmp"] ENTRYPOINT ["/go/bin/all-in-one-linux"] CMD ["--sampling.strategies-file=/etc/jaeger/sampling_strategies.json"] + +FROM $debug_image AS debug +ARG TARGETARCH=amd64 + +# Agent zipkin.thrift compact +EXPOSE 5775/udp + +# Agent jaeger.thrift compact +EXPOSE 6831/udp + +# Agent jaeger.thrift binary +EXPOSE 6832/udp + +# Agent config HTTP +EXPOSE 5778 + +# Collector HTTP +EXPOSE 14268 + +# Collector gRPC +EXPOSE 14250 + +# Web HTTP +EXPOSE 16686 + +# Delve +EXPOSE 12345 + +COPY all-in-one-debug-linux-$TARGETARCH /go/bin/all-in-one-linux +COPY sampling_strategies.json /etc/jaeger/ + +VOLUME ["/tmp"] +ENTRYPOINT ["/go/bin/dlv", "exec", "/go/bin/all-in-one-linux", "--headless", "--listen=:12345", "--api-version=2", "--accept-multiclient", "--log", "--"] +CMD ["--sampling.strategies-file=/etc/jaeger/sampling_strategies.json"] diff --git a/cmd/collector/Dockerfile b/cmd/collector/Dockerfile index 052db62044f..c33cedfce9c 100644 --- a/cmd/collector/Dockerfile +++ b/cmd/collector/Dockerfile @@ -1,10 +1,14 @@ -FROM alpine:latest as certs -RUN apk add --update --no-cache ca-certificates +ARG base_image +ARG debug_image -FROM scratch +FROM $base_image AS release ARG TARGETARCH=amd64 -COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt - -EXPOSE 14250 COPY collector-linux-$TARGETARCH /go/bin/collector-linux +EXPOSE 14250/tcp ENTRYPOINT ["/go/bin/collector-linux"] + +FROM $debug_image AS debug +ARG TARGETARCH=amd64 +COPY collector-debug-linux-$TARGETARCH /go/bin/collector-linux +EXPOSE 12345/tcp 14250/tcp +ENTRYPOINT ["/go/bin/dlv", "exec", "/go/bin/collector-linux", "--headless", "--listen=:12345", "--api-version=2", "--accept-multiclient", "--log", "--"] diff --git a/cmd/ingester/Dockerfile b/cmd/ingester/Dockerfile index 7cd5656def5..8aa6c86e1ca 100644 --- a/cmd/ingester/Dockerfile +++ b/cmd/ingester/Dockerfile @@ -1,11 +1,14 @@ -FROM alpine:latest as certs -RUN apk add --update --no-cache ca-certificates +ARG base_image +ARG debug_image -FROM scratch +FROM $base_image AS release ARG TARGETARCH=amd64 -COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt - -EXPOSE 14270 -EXPOSE 14271 COPY ingester-linux-$TARGETARCH /go/bin/ingester-linux +EXPOSE 14270/tcp 14271/tcp ENTRYPOINT ["/go/bin/ingester-linux"] + +FROM $debug_image AS debug +ARG TARGETARCH=amd64 +COPY ingester-debug-linux-$TARGETARCH /go/bin/ingester-linux +EXPOSE 12345/tcp 14270/tcp 14271/tcp +ENTRYPOINT ["/go/bin/dlv", "exec", "/go/bin/ingester-linux", "--headless", "--listen=:12345", "--api-version=2", "--accept-multiclient", "--log", "--"] diff --git a/cmd/query/Dockerfile b/cmd/query/Dockerfile index 7381994bd39..1cd2cb542fd 100644 --- a/cmd/query/Dockerfile +++ b/cmd/query/Dockerfile @@ -1,12 +1,14 @@ -FROM alpine:latest as certs -RUN apk add --update --no-cache ca-certificates +ARG base_image +ARG debug_image -FROM scratch +FROM $base_image AS release ARG TARGETARCH=amd64 - -COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt - -EXPOSE 16686 COPY query-linux-$TARGETARCH /go/bin/query-linux - +EXPOSE 16686/tcp ENTRYPOINT ["/go/bin/query-linux"] + +FROM $debug_image AS debug +ARG TARGETARCH=amd64 +COPY query-debug-linux-$TARGETARCH /go/bin/query-linux +EXPOSE 12345/tcp 16686/tcp +ENTRYPOINT ["/go/bin/dlv", "exec", "/go/bin/query-linux", "--headless", "--listen=:12345", "--api-version=2", "--accept-multiclient", "--log", "--"] diff --git a/docker/Makefile b/docker/Makefile new file mode 100644 index 00000000000..7ae41af9273 --- /dev/null +++ b/docker/Makefile @@ -0,0 +1,20 @@ +VERSION := 1.0.0 +ROOT_IMAGE ?= alpine:3.12 +CERT_IMAGE := alpine:3.12 +GOLANG_IMAGE := golang:1.15-alpine + +BASE_IMAGE := localhost/baseimg:$(VERSION)-$(shell echo $(ROOT_IMAGE) | tr : -) +DEBUG_IMAGE := localhost/debugimg:$(VERSION)-$(shell echo $(GOLANG_IMAGE) | tr : -) + +create-baseimg-debugimg: create-baseimg create-debugimg + +create-baseimg: + docker build -t $(BASE_IMAGE) \ + --build-arg root_image=$(ROOT_IMAGE) \ + --build-arg cert_image=$(CERT_IMAGE) \ + docker/base + +create-debugimg: + docker build -t $(DEBUG_IMAGE) \ + --build-arg golang_image=$(GOLANG_IMAGE) \ + docker/debug diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile new file mode 100644 index 00000000000..f22e85c4b83 --- /dev/null +++ b/docker/base/Dockerfile @@ -0,0 +1,8 @@ +ARG cert_image +ARG root_image + +FROM $cert_image AS cert +RUN apk add --update --no-cache ca-certificates + +FROM $root_image +COPY --from=cert /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt diff --git a/docker/debug/Dockerfile b/docker/debug/Dockerfile new file mode 100644 index 00000000000..487d7205590 --- /dev/null +++ b/docker/debug/Dockerfile @@ -0,0 +1,12 @@ +ARG golang_image + +FROM $golang_image AS build +ENV GOPATH /go +RUN apk add --update --no-cache ca-certificates make git && \ + go get github.com/go-delve/delve/cmd/dlv && \ + cd /go/src/github.com/go-delve/delve && \ + make install + +FROM $golang_image +COPY --from=build /go/bin/dlv /go/bin/dlv +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt diff --git a/scripts/travis/build-all-in-one-image.sh b/scripts/travis/build-all-in-one-image.sh index aca77aff401..8b390da13e7 100755 --- a/scripts/travis/build-all-in-one-image.sh +++ b/scripts/travis/build-all-in-one-image.sh @@ -40,7 +40,23 @@ upload_to_docker() { make build-all-in-one GOOS=linux GOARCH=$GOARCH repo=jaegertracing/all-in-one -docker build -f cmd/all-in-one/Dockerfile -t $repo:latest cmd/all-in-one --build-arg TARGETARCH=$GOARCH +docker build -f cmd/all-in-one/Dockerfile \ + --target release \ + --tag $repo:latest cmd/all-in-one \ + --build-arg base_image=localhost/baseimg:1.0.0-alpine-3.12 \ + --build-arg debug_image=localhost/debugimg:1.0.0-golang-1.15-alpine \ + --build-arg TARGETARCH=$GOARCH +run_integration_test $repo +upload_to_docker $repo + +make build-all-in-one-debug GOOS=linux GOARCH=$GOARCH +repo=jaegertracing/all-in-one-debug +docker build -f cmd/all-in-one/Dockerfile \ + --target debug \ + --tag $repo:latest cmd/all-in-one \ + --build-arg base_image=localhost/baseimg:1.0.0-alpine-3.12 \ + --build-arg debug_image=localhost/debugimg:1.0.0-golang-1.15-alpine \ + --build-arg TARGETARCH=$GOARCH run_integration_test $repo upload_to_docker $repo diff --git a/scripts/travis/upload-all-docker-images.sh b/scripts/travis/upload-all-docker-images.sh index 8d2e869f4da..061ac8c4169 100755 --- a/scripts/travis/upload-all-docker-images.sh +++ b/scripts/travis/upload-all-docker-images.sh @@ -20,7 +20,26 @@ else fi export DOCKER_NAMESPACE=jaegertracing -for component in agent cassandra-schema es-index-cleaner es-rollover collector query ingester tracegen opentelemetry-collector opentelemetry-agent opentelemetry-ingester + +jaeger_components=( + agent + agent-debug + cassandra-schema + es-index-cleaner + es-rollover + collector + collector-debug + query + query-debug + ingester + ingester-debug + tracegen + opentelemetry-collector + opentelemetry-agent + opentelemetry-ingester +) + +for component in "${jaeger_components[@]}" do export REPO="jaegertracing/jaeger-${component}" bash ./scripts/travis/upload-to-docker.sh