-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (61 loc) · 1.8 KB
/
Makefile
File metadata and controls
73 lines (61 loc) · 1.8 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
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
# COLORS
TARGET_MAX_CHAR_NUM := 10
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
# The binary to build (just the basename).
BIN ?= haproxy-configuration-builder
ORG ?= vbouchaud
# This version-strategy uses git tags to set the version string
GIT_TAG := $(shell git describe --tags --always --dirty || echo unsupported)
GIT_COMMIT := $(shell git rev-parse --short HEAD || echo unsupported)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
BUILDTIME := $(shell date -u +"%FT%TZ%:z")
TAG ?= $(GIT_TAG)
.PHONY: docker tag push help
default: help
## Build the docker image
docker:
@docker build \
--pull \
--tag "$(ORG)/$(BIN):latest" \
.
## Tag image
tag: docker
@docker tag "$(ORG)/$(BIN):latest" "$(ORG)/$(BIN):$(TAG)"
## Push the latest and current version tags to registry
push: tag
@docker push "$(ORG)/$(BIN):latest"
@docker push "$(ORG)/$(BIN):$(TAG)"
## Run the latest built image
run: docker
@docker run \
-it \
--rm \
"$(ORG)/$(BIN):latest"
## Run a shell on the latest built image
run-shell: docker
@docker run \
-it \
--rm \
"$(ORG)/$(BIN):latest" sh
## Same as push
all: push
## Print this help message
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)