blob: 0a8bdcf60c4b80b2758fa135e1332a6e254ba226 [file] [log] [blame]
David K. Bainbridge528b3182017-01-23 08:51:59 -08001IMAGE_NAME=cord-provisioner
2BINARY=entry-point
3BUILD_TAG=build
4PACKAGE_TAG=candidate
5
6.PHONY: help
7help:
8 @echo "build - create the binary"
9 @echo "package - package the binary into a docker container"
10 @echo "clean - remove tempory files and build artifacts"
11 @echo "help - this message"
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
22.PHONY: build
23build:
24 docker build -t $(IMAGE_NAME):$(BUILD_TAG) .
25
26.PHONY: package
27package:
28 $(eval BUILD_ID := $(shell docker create $(IMAGE_NAME):$(BUILD_TAG)))
29 $(eval BINDIR := $(shell mktemp -d))
30 docker cp $(BUILD_ID):/service/$(BINARY) $(BINDIR)/$(BINARY)
David K. Bainbridgea75d3702017-05-19 14:11:59 -070031 cp Dockerfile.release ssh-config ansible.cfg $(BINDIR)
David K. Bainbridge528b3182017-01-23 08:51:59 -080032 docker build -f $(BINDIR)/Dockerfile.release -t $(IMAGE_NAME):$(PACKAGE_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) $(BINDIR)
33 docker rm -f $(BUILD_ID)
34 rm -r $(BINDIR)
35
36.PHONY: clean
37clean:
38 @echo ""