David K. Bainbridge | 0a7cdbb | 2017-07-14 11:36:13 -0700 | [diff] [blame] | 1 | .PRECIOUS: Dockerfile.image |
| 2 | |
| 3 | ifneq ($(MAKE_CONFIG),) |
| 4 | include $(MAKE_CONFIG) |
| 5 | endif |
| 6 | |
| 7 | PROJECT_PREFIX?=opencord/maas- |
| 8 | |
| 9 | ifeq ($(DOCKER_TAG),) |
| 10 | DOCKER_TAG:=candidate |
| 11 | endif |
| 12 | |
| 13 | BUILD_DATE=$(shell date -u +%Y-%m-%dT%TZ) |
| 14 | VCS_REF=$(shell git log --pretty=format:%H -n 1) |
| 15 | VCS_REF_DATE=$(shell git log --pretty=format:%cd --date=format:%FT%T%z -n 1) |
| 16 | BRANCHES=$(shell repo --color=never --no-pager branches 2>/dev/null | wc -l) |
| 17 | STATUS=$(shell repo --color=never --no-pager status . | tail -n +2 | wc -l) |
| 18 | MODIFIED=$(shell test $(BRANCHES) -eq 0 && test $(STATUS) -eq 0 || echo "[modified]") |
| 19 | BRANCH=$(shell repo --color=never --no-pager info -l -o | grep 'Manifest branch:' | awk '{print $$NF}') |
| 20 | VERSION=$(BRANCH)$(MODIFIED) |
| 21 | |
| 22 | include ../help.mk |
| 23 | |
| 24 | build: $(addsuffix .image,$(IMAGES)) |
| 25 | |
| 26 | publish: $(addsuffix .publish,$(IMAGES)) |
| 27 | |
| 28 | test: |
| 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 : |
| 40 | ifdef 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) |
| 44 | else |
| 45 | @echo "No registry was specified, cannot PUSH image" |
| 46 | endif |
| 47 | |
| 48 | clean: |