This repository has been archived by the owner on Aug 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
133 lines (102 loc) · 3.92 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
VERSION = $(subst v,,$(shell git config -f .gitmodules submodule.jaeger.tag))
DOCKERX = docker buildx build --push
HUB = docker.io/querycapjaegertracing
TARGET_ARCHS = amd64 arm64
COMPONENT = query
IMAGE_NAME = jaeger-$(COMPONENT)
BASE_IMAGE_COMPONENT = baseimg debugimg
IMAGE_WITHOUT_JAEGER_PREFIX = $(BASE_IMAGE_COMPONENT) all-in-one all-in-one-debug
ifneq (,$(findstring $(COMPONENT),$(IMAGE_WITHOUT_JAEGER_PREFIX)))
IMAGE_NAME = $(COMPONENT)
endif
BACKEND_COMPONENT = \
all-in-one \
all-in-one-debug \
agent \
agent-debug \
collector \
collector-debug \
query \
query-debug \
ingester \
ingester-debug \
BIN_COMPONENT = $(BACKEND_COMPONENT) tracegen
PLUGIN_COMPONENT = \
cassandra-schema \
es-index-cleaner \
es-rollover
COMPONENTS = $(BIN_COMPONENT) $(PLUGIN_COMPONENT)
ifneq (,$(findstring $(COMPONENT),$(BACKEND_COMPONENT)))
ifneq (,$(findstring -debug,$(COMPONENT)))
DOCKERX := $(DOCKERX) --target=debug
else
DOCKERX := $(DOCKERX) --target=release
endif
endif
ROOT_IMAGE = alpine:3.12
CERT_IMAGE = $(ROOT_IMAGE)
GOLANG_IMAGE = golang:1.15-alpine
BASE_IMG_TAG = 1.0.0-$(subst :,-,$(ROOT_IMAGE))
DEBUG_IMG_TAG = 1.0.0-$(subst :,-,$(GOLANG_IMAGE))
WORKSPACE = ./jaeger/cmd/$(subst -debug,,$(COMPONENT))
DOCKERFILE = $(WORKSPACE)/Dockerfile
BUILD_ARGS = base_image=$(HUB)/baseimg:$(BASE_IMG_TAG) debug_image=$(HUB)/debugimg:$(DEBUG_IMG_TAG)
# base image
ifneq (,$(findstring $(COMPONENT),$(BASE_IMAGE_COMPONENT)))
WORKSPACE = ./jaeger/docker/$(subst img,,$(COMPONENT))
BUILD_ARGS = root_image=$(ROOT_IMAGE) cert_image=$(CERT_IMAGE)
VERSION = $(BASE_IMG_TAG)
ifeq (debugimg,$(COMPONENT))
BUILD_ARGS = golang_image=$(GOLANG_IMAGE)
VERSION = $(DEBUG_IMG_TAG)
endif
endif
ifeq (cassandra-schema,$(COMPONENT))
WORKSPACE = ./jaeger/plugin/storage/cassandra
endif
ifeq (es-index-cleaner,$(COMPONENT))
WORKSPACE = ./jaeger/plugin/storage/es
endif
ifeq (es-rollover,$(COMPONENT))
WORKSPACE = ./jaeger/plugin/storage/es
DOCKERFILE = $(WORKSPACE)/Dockerfile.rollover
endif
info:
@echo "====="
@echo "component: $(COMPONENT), workspace: $(WORKSPACE), img: $(foreach h,$(HUB),$(h)/$(IMAGE_NAME):$(VERSION))"
@echo "====="
install-esc:
@if ! esc > /dev/null 2>&1; then \
cd jaeger && go get -u github.com/mjibson/esc; \
fi
buildx-bin: install-esc
ifneq (,$(findstring $(COMPONENT),$(BIN_COMPONENT)))
cd jaeger && sh -c "$(foreach arch,$(TARGET_ARCHS),make build-$(COMPONENT) GOOS=linux GOARCH=$(arch);)"
endif
patch-dockerfile:
@sed -i -e 's/ARG TARGETARCH=amd64/ARG TARGETARCH/g' "$(DOCKERFILE)"
@echo "======Dockerfile======"
@cat "$(WORKSPACE)/Dockerfile"
@echo "===================="
dockerx: info buildx-bin patch-dockerfile
$(DOCKERX) \
$(foreach arg,$(BUILD_ARGS),--build-arg=$(arg)) \
$(foreach h,$(HUB),--tag=$(h)/$(IMAGE_NAME):$(VERSION)) \
$(foreach p,$(TARGET_ARCHS),--platform=linux/$(p)) \
--file=$(DOCKERFILE) $(WORKSPACE)
cleanup:
git submodule foreach 'git add . && git reset --hard'
dep:
git submodule update --init
git submodule foreach 'tag="$$(git config -f $$toplevel/.gitmodules submodule.$$name.tag)"; if [ -n $$tag ]; then git fetch --tags && git checkout $$tag && git submodule update --init; fi'
sync-crd:
wget -O charts/jaeger-operator/crds/jaegertracing.io_jaegers_crd.yaml https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/crds/jaegertracing.io_jaegers_crd.yaml
img = $(subst docker.io/,,$(word 1,$(HUB))/$(IMAGE_NAME))
gen-doc:
@echo "\n## \`$(img):$(VERSION)\`"
@echo "[![Docker Version](https://img.shields.io/docker/v/$(img)?sort=semver)](https://hub.docker.com/r/$(img)/tags)"
@echo "![Docker Image Size](https://img.shields.io/docker/image-size/$(img)?sort=semver)"
@echo "![Docker Pulls](https://img.shields.io/docker/pulls/$(img))"
gen-docs:
@echo "# [\`jaeger\`](https://github.com/jaegertracing/jaeger) multi arch images" > README.md
@sh -c "$(foreach comp,$(COMPONENTS),make gen-doc COMPONENT=$(comp) >> README.md;)"