This repository has been archived by the owner on Nov 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile.inc
96 lines (75 loc) · 2.72 KB
/
Makefile.inc
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
96
# Binaries
DOCKER = docker
# This makes sure that regex match for vVALID, vPATCH and vRC is working
SHELL = /bin/bash
# Other, centralised settings
FLAVOUR ?= corteza
ifeq ($(VERSION),)
$(error VERSION is not set. Make sure you specify it, eg: make build VERSION=2021.3.0)
endif
# Trying to build old version?
vPRE2021 := $(shell [[ $(VERSION) =~ ^2020 ]] && echo "yes")
ifneq ($(vPRE2021),)
$(error Refusing to build versions older than 2021.3.x, please checkout 2020.12.x branch of this repo and build with that)
endif
vFULL := $(VERSION)
# Is this a valid version (fits in a "yyyy.<3, 6 9 or 12>.<patch>" format)?
vVALID := $(shell [[ $(vFULL) =~ ^202[0-9].(3|6|9|12)(.[0-9]+)?$$ ]] && echo "yes")
# Is this a patch?
vPATCH := $(shell [[ $(vFULL) =~ ^202[0-9].(3|6|9|12).([0-9]+)$$ ]] && echo "yes")
# Is this a release candidate?
vRC := $(shell [[ $(vFULL) =~ \-rc.([0-9]+)$$ ]] && echo "yes")
ifneq ($(vVALID),)
ifeq ($(vPATCH),)
vFULL := $(addsuffix .0,$(vFULL))
endif
endif
# The actual shorten version:
vSHORT := $(word 1,$(subst ., ,$(vFULL))).$(word 2,$(subst ., ,$(vFULL)))
ifeq ($(FLAVOUR),crust)
IMAGE_PFIX = crusttech/crust-
else
IMAGE_PFIX = cortezaproject/corteza-
endif
VERSION ?= $(vFULL)
VERSION_WEBAPP ?= $(VERSION)
VERSION_WEBAPP_ONE ?= $(VERSION_WEBAPP)
VERSION_WEBAPP_ADMIN ?= $(VERSION_WEBAPP)
VERSION_WEBAPP_COMPOSE ?= $(VERSION_WEBAPP)
# Docker build flags, build arguments and combined options
DOCKER_BUILD_FLAGS ?= --no-cache --rm # example: make build.server DOCKER_BUILD_FLAGS=--rm
DOCKER_BUILD_FLAGS += --build-arg C_FLAVOUR=$(FLAVOUR)
DOCKER_BUILD_FLAGS += --build-arg C_VERSION=$(VERSION)
DOCKER_BUILD_FLAGS += --build-arg C_VERSION_WEBAPP=$(VERSION_WEBAPP)
DOCKER_BUILD_FLAGS += --build-arg C_VERSION_WEBAPP_ONE=$(VERSION_WEBAPP_ONE)
DOCKER_BUILD_FLAGS += --build-arg C_VERSION_WEBAPP_ADMIN=$(VERSION_WEBAPP_ADMIN)
DOCKER_BUILD_FLAGS += --build-arg C_VERSION_WEBAPP_COMPOSE=$(VERSION_WEBAPP_COMPOSE)
all: | build push
# Generic docker build
build:
$(DOCKER) build $(DOCKER_BUILD_FLAGS) --tag $(IMAGE):$(vFULL) .
ifeq ($(vVALID),yes)
docker tag $(IMAGE):$(vFULL) $(IMAGE):$(vSHORT)
ifeq ($(LATEST),yes)
docker tag $(IMAGE):$(vFULL) $(IMAGE):latest
endif
endif
# Generic docker push
push:
# @ echo "VERSION = <" $(VERSION) ">"
# @ echo "vFULL = <" $(vFULL) ">"
# @ echo "vVALID = <" $(vVALID) ">"
# @ echo "vPATCH = <" $(vPATCH) ">"
# @ echo "vRC = <" $(vRC) ">"
ifeq ($(vRC),yes)
@ echo "Refusing to automatically push release-candidate to docker hub, you can do it manually:"
@ echo docker push $(IMAGE):$(vFULL)
else
$(DOCKER) push $(IMAGE):$(vFULL)
ifeq ($(vVALID),yes)
docker push $(IMAGE):$(vSHORT)
ifeq ($(LATEST),yes)
docker push $(IMAGE):latest
endif
endif
endif