-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
58 lines (42 loc) · 1.4 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
.PHONY: docker-build docker-push docker-run run test
PY ?= python3
.DEFAULT_GOAL := help
define PRINT_HELP_PYSCRIPT
import re, sys
targets = []
variables = []
print("Targets:\n")
for line in sys.stdin:
match = re.search(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
targets.append("%-20s %s" % (target, help))
vars = re.search(r'([A-Z_]+).*#\? (.*)$$', line)
if vars:
target, help = vars.groups()
variables.append("%-20s %s" % (target, help))
print('\n'.join(targets))
if variables:
print("\nVariable you can override: ")
print('\n'.join(variables))
endef
export PRINT_HELP_PYSCRIPT
run:## run the application
python3 app.py
test: ## run a rudimentary test
python3 test.py
help:
@$(PY) -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
REGISTRY ?= registry.tiram.it#? container registry to push
ORG ?= oz123#? organization to push to
IMG ?= pwman-notifier#? image name
TAG ?= $(shell git describe --always)#? tag name
OPTS ?=
# usage: make docker-build TAG=0.1
docker-build:: ## build a docker image
docker build $(OPTS) -t $(REGISTRY)/$(ORG)/$(IMG):v$(TAG) -f docker/Dockerfile .
docker-push::
docker push $(REGISTRY)/$(ORG)/$(IMG):v$(TAG)
docker-run:: ## run the docker image locally
sudo chown -vR 33:33 $(CURDIR)/data/
sudo docker run -it -p 9001:9001 -v $(CURDIR)/data:/var/lib/app/db:rw $(REGISTRY)/$(ORG)/$(IMG):v$(TAG)