pkg: Convert format to use the Alpine base and git tree hash

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer
2017-05-04 14:41:09 +01:00
parent 43d97967ef
commit fce13fb48d
2 changed files with 22 additions and 32 deletions

View File

@@ -1,29 +1,14 @@
.PHONY: tag push
BASE=alpine:3.5
IMAGE=format
default: push
hash: Dockerfile format.sh
DOCKER_CONTENT_TRUST=1 docker pull $(BASE)
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
docker run --rm --entrypoint /bin/sh $(IMAGE):build -c "cat $^ /lib/apk/db/installed | sha1sum" | sed 's/ .*//' > $@
IMAGE=format
DEPS=Dockerfile format.sh
push: hash
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
HASH?=$(shell git ls-tree HEAD -- ../$(notdir $(CURDIR)) | awk '{print $$3}')
tag: hash
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash)
docker rmi $(IMAGE):build
rm -f hash
tag: $(DEPS)
docker build --squash --no-cache --network=none -t linuxkit/$(IMAGE):$(HASH) .
clean:
rm -f hash
.DELETE_ON_ERROR:
push: tag
docker pull linuxkit/$(IMAGE):$(HASH) || \
docker push linuxkit/$(IMAGE):$(HASH)