forked from ITISFoundation/IEC62209-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (57 loc) · 1.75 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
include ./scripts/common.Makefile
APP_NAME := iec62209-service
IMAGE_NAME ?= local/${APP_NAME}:latest
PHONY: info
info: ## info on tools and environs
# environs tools
@which python
@python --version
@which pip
@pip --version
# environs
@echo 'IMAGE_NAME =${IMAGE_NAME}'
.venv:
@python3 --version
python3 -m venv $@
## upgrading tools to latest version in $(shell python3 --version)
$@/bin/pip3 --quiet install --upgrade \
pip~=23.0 \
wheel \
setuptools
@$@/bin/pip3 list --verbose
.PHONY: update-version
update-version:
@. update_version.sh
.PHONY: devenv
devenv: .venv ## create a python virtual environment with dev tools (e.g. linters, etc)
$</bin/pip3 --quiet install -r requirements-dev.txt
# Installing pre-commit hooks in current .git repo
@$</bin/pre-commit install
@echo "To activate the venv, execute 'source .venv/bin/activate'"
.PHONY: client
client: update-version ## installs and compiles client
$(MAKE_C) client install
$(MAKE_C) client compile
.PHONY: server
server: update-version _check_venv_active ## installs and runs server (devel mode)
$(MAKE_C) server install-dev
$(MAKE_C) server run-dev
.PHONY: build build-nc
build build-nc: update-version ## build image. Suffix -nc disables cache
docker build \
$(if $(findstring -nc,$@),--no-cache,) \
--tag ${IMAGE_NAME} \
$(CURDIR)
.PHONY: run
run: update-version ## runs container and serves in http://127.0.0.1:8000/
docker run \
--tty \
--interactive \
--publish 8000:8000 \
${IMAGE_NAME}
clean-venv: devenv ## Purges .venv into original configuration
# Cleaning your venv
.venv/bin/pip-sync --quiet $(CURDIR)/requirements/devenv.txt
@pip list
clean-hooks: ## Uninstalls git pre-commit hooks
@-pre-commit uninstall 2> /dev/null || rm .git/hooks/pre-commit