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