-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
39 lines (32 loc) · 1.46 KB
/
Makefile
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
##
## The "push" target assumes that AWS credentials have been configured.
##
CNT_NAME := scimma/python-service-base
TAG := $(shell git log -1 --pretty=%H || echo MISSING )
CNT_IMG := $(CNT_NAME):$(TAG)
CNT_LTST := $(CNT_NAME):latest
.PHONY: set-release-tags push all container
all: container
print-% : ; @echo $* = $($*)
container: Dockerfile
docker build -f $< -t $(CNT_IMG) .
docker tag $(CNT_IMG) $(CNT_LTST)
set-release-tags:
@$(eval TAG_SUFFIX := $(shell if [ ! -z "$$(git status --porcelain)" ]; then echo '-modified'; fi))
@$(eval RELEASE_TAG := $(shell git describe --tags --abbrev=0 | awk -F- '{print $$2}')"$(TAG_SUFFIX)")
@echo RELEASE_TAG = $(RELEASE_TAG)
@$(eval MAJOR_TAG := $(shell echo $(RELEASE_TAG) | awk -F. '{print $$1}'))
@echo MAJOR_TAG = $(MAJOR_TAG)
@$(eval MINOR_TAG := $(shell echo $(RELEASE_TAG) | awk -F. '{print $$2}'))
@echo MINOR_TAG = $(MINOR_TAG)
push: set-release-tags
@(echo $(RELEASE_TAG) | grep '^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$$' > /dev/null ) || (echo Bad release tag: $(RELEASE_TAG) && exit 1)
@eval "echo $$BUILDERCRED" | docker login --username $(BUILDER) --password-stdin
docker tag $(CNT_IMG) $(CNT_NAME):$(RELEASE_TAG)
docker tag $(CNT_IMG) $(CNT_NAME):$(MAJOR_TAG)
docker tag $(CNT_IMG) $(CNT_NAME):$(MAJOR_TAG).$(MINOR_TAG)
docker push $(CNT_NAME):$(RELEASE_TAG)
docker push $(CNT_NAME):$(MAJOR_TAG)
docker push $(CNT_NAME):$(MAJOR_TAG).$(MINOR_TAG)
docker push $(CNT_LTST)
rm -f $(HOME)/.docker/config.json