blob: a47303e2ac29815dc92334bfa74f072ec7c1da13 [file] [log] [blame]
David K. Bainbridge0a7cdbb2017-07-14 11:36:13 -07001.PRECIOUS: Dockerfile.image
2
3ifneq ($(MAKE_CONFIG),)
4include $(MAKE_CONFIG)
5endif
6
7PROJECT_PREFIX?=opencord/maas-
8
9ifeq ($(DOCKER_TAG),)
10DOCKER_TAG:=candidate
11endif
12
13BUILD_DATE=$(shell date -u +%Y-%m-%dT%TZ)
14VCS_REF=$(shell git log --pretty=format:%H -n 1)
15VCS_REF_DATE=$(shell git log --pretty=format:%cd --date=format:%FT%T%z -n 1)
16BRANCHES=$(shell repo --color=never --no-pager branches 2>/dev/null | wc -l)
17STATUS=$(shell repo --color=never --no-pager status . | tail -n +2 | wc -l)
18MODIFIED=$(shell test $(BRANCHES) -eq 0 && test $(STATUS) -eq 0 || echo "[modified]")
19BRANCH=$(shell repo --color=never --no-pager info -l -o | grep 'Manifest branch:' | awk '{print $$NF}')
20VERSION=$(BRANCH)$(MODIFIED)
21
22include ../help.mk
23
24build: $(addsuffix .image,$(IMAGES))
25
26publish: $(addsuffix .publish,$(IMAGES))
27
28test:
29 @echo "Really should have some tests"
30
31%.image : Dockerfile.%
32 docker build $(DOCKER_ARGS) -f Dockerfile.$(basename $@) \
33 -t $(PROJECT_PREFIX)$(basename $@):$(DOCKER_TAG) \
34 --label org.label-schema.build-date=$(BUILD_DATE) \
35 --label org.label-schema.vcs-ref=$(VCS_REF) \
36 --label org.label-schema.vcs-ref-date=$(VCS_REF_DATE) \
37 --label org.label-schema.version=$(VERSION) .
38
39%.publish :
40ifdef DOCKER_REGISTRY
41 $(eval BASENAME := $(basename $@):$(DOCKER_TAG))
42 docker tag $(PROJECT_PREFIX)$(BASENAME) $(DOCKER_REGISTRY)/$(PROJECT_PREFIX)$(BASENAME)
43 docker push $(DOCKER_REGISTRY)/$(PROJECT_PREFIX)$(BASENAME)
44else
45 @echo "No registry was specified, cannot PUSH image"
46endif
47
48clean: