-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
55 lines (48 loc) · 2.02 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
TARGET_DOCKER_REGISTRY_URL?=https://hub.docker.com/v2/repositories/
DOCKER_IMAGE_NAME?=mbenabda/promtool
PROMTOOL_VERSION=
BASE_IMAGE=
.PHONY: build publish sync sync_missing_versions
build:
docker build --build-arg=PROMTOOL_VERSION=$(PROMTOOL_VERSION) \
--build-arg=BASE_IMAGE=scratch \
. -t $(DOCKER_IMAGE_NAME):$(PROMTOOL_VERSION)
docker build --build-arg=PROMTOOL_VERSION=$(PROMTOOL_VERSION) \
--build-arg=BASE_IMAGE=alpine:3.8 \
. -t $(DOCKER_IMAGE_NAME):$(PROMTOOL_VERSION)-alpine
publish:
docker push $(DOCKER_IMAGE_NAME):$(PROMTOOL_VERSION)
docker push $(DOCKER_IMAGE_NAME):$(PROMTOOL_VERSION)-alpine
sync: build publish
sync_missing_versions:
set -e; \
TMP=$$(mktemp -d); \
touch "$$TMP/promtool.tags"; \
touch "$$TMP/prometheus.tags"; \
\
curl -s https://hub.docker.com/v2/repositories/prom/prometheus/tags/ > $$TMP/page.json; \
cat $$TMP/page.json | jq -r '.results[] | .name' >> "$$TMP/prometheus.tags"; \
NEXT_PAGE=$$(cat $$TMP/page.json | jq -rM '.next'); \
while [ "$$NEXT_PAGE" != "null" ]; \
do \
sleep 0.5; \
curl -s "$$NEXT_PAGE" > $$TMP/page.json; \
cat $$TMP/page.json | jq -r '.results[] | .name' >> "$$TMP/prometheus.tags"; \
NEXT_PAGE=$$(cat $$TMP/page.json | jq -rM '.next'); \
done; \
\
curl -s $(TARGET_DOCKER_REGISTRY_URL)$(DOCKER_IMAGE_NAME)/tags/ > $$TMP/page.json; \
cat $$TMP/page.json | jq -r '.results[] | .name' >> "$$TMP/promtool.tags"; \
NEXT_PAGE=$$(cat $$TMP/page.json | jq -rM '.next'); \
while [ "$$NEXT_PAGE" != "null" ]; \
do \
sleep 0.5; \
curl -s "$$NEXT_PAGE" > $$TMP/page.json; \
cat $$TMP/page.json | jq -r '.results[] | .name' >> "$$TMP/promtool.tags"; \
NEXT_PAGE=$$(cat $$TMP/page.json | jq -rM '.next'); \
done; \
\
(grep -v -x -f "$$TMP/promtool.tags" "$$TMP/prometheus.tags" > "$$TMP/missing.tags") || true; \
(grep -v -x -f blacklist.tags "$$TMP/missing.tags" > "$$TMP/filtered_missing.tags") || true; \
touch "$$TMP/filtered_missing.tags"; \
cat "$$TMP/filtered_missing.tags" | sort | xargs -I{} -n1 bash -c "make sync PROMTOOL_VERSION={}"; \