Files
linuxkit/pkg/package.mk
Ian Campbell 7fd155b38d pkg: Do not mark user supplied HASH as dirty
If a user passes a HASH e.g. HASH=dev then assume they know what they are doing
and don't need dirty tracking.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-07-03 10:27:31 +01:00

44 lines
1.0 KiB
Makefile

.PHONY: image tag show-tag
default: push
ORG?=linuxkit
ifeq ($(HASH),)
HASH_COMMIT?=HEAD # Setting this is only really useful with the show-tag target
HASH?=$(shell git ls-tree --full-tree $(HASH_COMMIT) -- $(CURDIR) | awk '{print $$3}')
ifneq ($(HASH_COMMIT),HEAD) # Others can't be dirty by definition
DIRTY=$(shell git diff-index --quiet HEAD -- $(CURDIR) || echo "-dirty")
endif
endif
TAG=$(ORG)/$(IMAGE):$(HASH)$(DIRTY)
BASE_DEPS=Dockerfile Makefile
# Get a release tag, if present
RELEASE=$(shell git tag -l --points-at HEAD)
ifdef NETWORK
NET_OPT=
else
NET_OPT=--network=none
endif
show-tag:
@echo $(TAG)
tag: $(BASE_DEPS) $(DEPS)
DOCKER_CONTENT_TRUST=1 docker pull $(TAG) || \
docker build $(NET_OPT) -t $(TAG) .
push: tag
ifneq ($(DIRTY),)
$(error Your repository is not clean. Will not push package image.)
endif
DOCKER_CONTENT_TRUST=1 docker pull $(TAG) || \
DOCKER_CONTENT_TRUST=1 docker push $(TAG)
ifneq ($(RELEASE),)
docker tag $(TAG) $(ORG)/$(IMAGE):$(RELEASE)
DOCKER_CONTENT_TRUST=1 docker push $(ORG)/$(IMAGE):$(RELEASE)
endif