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

Create debug docker images for jaeger backends #2545

Merged
merged 8 commits into from
Oct 20, 2020
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

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

Why is the extra step make create-baseimg-debugimg needed here but not in DOCKER step in L73?
Also, why not call it from ./scripts/travis/build-all-in-one-image.sh?

Copy link
Contributor Author

@Ashmita152 Ashmita152 Oct 21, 2020

Choose a reason for hiding this comment

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

Why is the extra step make create-baseimg-debugimg needed here but not in DOCKER step in L73?

My understanding is that script calls: make docker -> make docker-images-only -> make docker-images-jaeger-backend-debug which has dependencies on create-baseimg and create-debugimg.

Also, why not call it from ./scripts/travis/build-all-in-one-image.sh?

We can do it if you think that is the better place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably be done after #2325, as it touches this code as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

if need to support multi arch for other components.

base images need to published with multi arch too.
or just upgrade Dockerfile like https://github.com/morlay/jaeger/blob/master/cmd/all-in-one/Dockerfile

- 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
Expand Down
72 changes: 52 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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' \
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 \
jpkrohling marked this conversation as resolved.
Show resolved Hide resolved
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
Expand All @@ -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)
Expand All @@ -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:
Expand Down
17 changes: 11 additions & 6 deletions cmd/agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 link
Member

Choose a reason for hiding this comment

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

@Ashmita152 was there a reason for TARGETARCH and USER_UID args to be repeated in each target, instead of being defined at the top of the file?

If not, probably another opportunity to clean up / DRY the docker files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will clean that today.

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}
42 changes: 37 additions & 5 deletions cmd/all-in-one/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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"]
16 changes: 10 additions & 6 deletions cmd/collector/Dockerfile
Original file line number Diff line number Diff line change
@@ -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", "--"]
17 changes: 10 additions & 7 deletions cmd/ingester/Dockerfile
Original file line number Diff line number Diff line change
@@ -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", "--"]
18 changes: 10 additions & 8 deletions cmd/query/Dockerfile
Original file line number Diff line number Diff line change
@@ -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", "--"]
20 changes: 20 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions docker/debug/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
18 changes: 17 additions & 1 deletion scripts/travis/build-all-in-one-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
jpkrohling marked this conversation as resolved.
Show resolved Hide resolved
--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

Expand Down
21 changes: 20 additions & 1 deletion scripts/travis/upload-all-docker-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down