mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-12-24 22:06:09 +00:00
This is like the `push` target but omits the pulls and depends on forcetag instead. With the git commit now being embedded into the image this is now a necessary part of rebasing a PR for which images have already been pushed. Also adds PHONY targets for existing forcetag and push targets which were missing. NB $(error) appends a "." to omit the final one from the error message Signed-off-by: Ian Campbell <ijc@docker.com>
76 lines
1.9 KiB
Makefile
76 lines
1.9 KiB
Makefile
.PHONY: image tag forcetag show-tag check-dirty push forcepush
|
|
default: push
|
|
|
|
ORG?=linuxkit
|
|
SOURCE ?= .
|
|
|
|
# Hash is of $(CURDIR) not $(CURDIR)$(SOURCE) to allow autogenerated
|
|
# source subdirectories (which would not be covered by ls-tree, but
|
|
# the code which autogenerates should be in $(CURDIR) so that is what
|
|
# we want to use.
|
|
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 update-index -q --refresh && git diff-index --quiet HEAD -- $(CURDIR) || echo "-dirty")
|
|
endif
|
|
endif
|
|
|
|
TAG:=$(ORG)/$(IMAGE):$(HASH)$(DIRTY)
|
|
|
|
REPO?=https://github.com/linuxkit/linuxkit
|
|
ifneq ($(REPO),)
|
|
REPO_LABEL=--label org.opencontainers.image.source=$(REPO)
|
|
endif
|
|
ifeq ($(DIRTY),)
|
|
REPO_COMMIT=$(shell git rev-parse HEAD)
|
|
COMMIT_LABEL=--label org.opencontainers.image.revision=$(REPO_COMMIT)
|
|
endif
|
|
LABELS=$(REPO_LABEL) $(COMMIT_LABEL)
|
|
|
|
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
|
|
|
|
ifeq ($(DOCKER_CONTENT_TRUST),)
|
|
ifndef NOTRUST
|
|
export DOCKER_CONTENT_TRUST=1
|
|
endif
|
|
endif
|
|
|
|
show-tag:
|
|
@echo $(TAG)
|
|
|
|
tag: $(BASE_DEPS) $(DEPS)
|
|
docker pull $(TAG) || docker build $(LABELS) $(NET_OPT) -t $(TAG) $(SOURCE)
|
|
|
|
forcetag: $(BASE_DEPS) $(DEPS)
|
|
docker build $(LABELS) $(NET_OPT) -t $(TAG) $(SOURCE)
|
|
|
|
check-dirty:
|
|
ifneq ($(DIRTY),)
|
|
$(error Your repository is not clean. Will not push package image)
|
|
endif
|
|
|
|
push: check-dirty tag
|
|
docker pull $(TAG) || docker push $(TAG)
|
|
ifneq ($(RELEASE),)
|
|
docker tag $(TAG) $(ORG)/$(IMAGE):$(RELEASE)
|
|
docker push $(ORG)/$(IMAGE):$(RELEASE)
|
|
endif
|
|
|
|
forcepush: check-dirty forcetag
|
|
docker push $(TAG)
|
|
ifneq ($(RELEASE),)
|
|
docker tag $(TAG) $(ORG)/$(IMAGE):$(RELEASE)
|
|
docker push $(ORG)/$(IMAGE):$(RELEASE)
|
|
endif
|