aboutsummaryrefslogtreecommitdiffstats
path: root/make/Makefile
blob: 231b68525766c1adc1f466b7c7d97a4d1ff69431 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#
#   Copyright 2015  Xebia Nederland B.V.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
REGISTRY_HOST?=docker.io
USERNAME?=$(USER)
NAME?=$(shell basename $(CURDIR))

RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-release-support
IMAGE?=$(REGISTRY_HOST)/$(NAME)

VERSION?=$(shell . $(RELEASE_SUPPORT) ; getRelease)

SHELL=/bin/bash

.PHONY: pre-build docker-build post-build build release patch-release minor-release major-release tag showver \
	push do-push post-push

build: pre-build docker-build post-build

pre-build:


post-build:


post-push:


docker-build: .release
	docker build --build-arg USER=$(USERNAME) -t $(IMAGE):latest .
	@DOCKER_MAJOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f1) ; \
	DOCKER_MINOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f2) ; \

tag: docker-build
	if [ $$DOCKER_MAJOR -eq 1 ] && [ $$DOCKER_MINOR -lt 10 ] ; then \
		echo docker tag -f $(IMAGE):latest $(IMAGE):$(VERSION) ;\
		docker tag -f $(IMAGE):latest $(IMAGE):$(VERSION) ;\
	else \
		echo docker tag $(IMAGE):latest $(IMAGE):$(VERSION) ;\
		docker tag $(IMAGE):latest $(IMAGE):$(VERSION) ; \
	fi

.release:
	@echo "release=0.0.0" > .release
	@echo INFO: .release created
	@cat .release


release: build push


push: do-push post-push 

do-push: 
	docker push $(IMAGE):latest
	[ -f .release ] && docker push $(IMAGE):$(VERSION)

snapshot: build push

showver: .release
	@. $(RELEASE_SUPPORT); getVersion

tag-patch-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextPatchLevel)
tag-patch-release: .release tag 

tag-minor-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMinorLevel)
tag-minor-release: .release tag 

tag-major-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMajorLevel)
tag-major-release: .release tag 

patch-release: tag-patch-release release
	@echo $(VERSION)

minor-release: tag-minor-release release
	@echo $(VERSION)

major-release: tag-major-release release
	@echo $(VERSION)


run:
	docker run $(RUN_ARGS) -it $(IMAGE)