pkg: Use git tree hash for the prometheus node_exporter

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-05-04 14:51:42 +01:00
parent 1748a69f2a
commit 41a1d16694
2 changed files with 9 additions and 24 deletions

View File

@ -1,4 +1,4 @@
FROM prom/node-exporter:v0.14.0
FROM prom/node-exporter:v0.14.0@sha256:ea8396dd32be6195ef03438b2f459b2e69a88b8fc798c3fc51559f56d4b158fa
ENTRYPOINT ["/bin/node_exporter", "-collector.procfs", "/host/proc", \
"-collector.sysfs", "/host/sys", \

View File

@ -1,29 +1,14 @@
.PHONY: tag push clean container
.PHONY: tag push
default: push
IMAGE=node_exporter
SHA_IMAGE=alpine:3.5@sha256:dfbd4a3a8ebca874ebd2474f044a0b33600d4523d03b0df76e5c5986cb02d7e8
DEPS=Dockerfile
container: Dockerfile
docker build --no-cache -t $(IMAGE):build .
HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}')
hash: Dockerfile
find $^ -type f | xargs cat | docker run --rm -i $(SHA_IMAGE) sha1sum - | sed 's/ .*//' > hash
tag: $(DEPS)
docker build --no-cache --network=none -t linuxkit/$(IMAGE):$(HASH) .
push: hash container
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
(docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) && \
docker push linuxkit/$(IMAGE):$(shell cat hash))
docker rmi $(IMAGE):build
rm -f hash
tag: hash container
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash)
docker rmi $(IMAGE):build
rm -f hash
clean:
rm -rf hash
.DELETE_ON_ERROR:
push: tag
docker pull linuxkit/$(IMAGE):$(HASH) || \
docker push linuxkit/$(IMAGE):$(HASH)