forked from pablobuenaposada/HonDash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
153 lines (122 loc) · 4.09 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
VIRTUAL_ENV ?= venv
PYTHON=$(VIRTUAL_ENV)/bin/python
PIP=$(VIRTUAL_ENV)/bin/pip
PYTEST=$(VIRTUAL_ENV)/bin/pytest
ISORT=$(VIRTUAL_ENV)/bin/isort
FLAKE8=$(VIRTUAL_ENV)/bin/flake8
COVERALLS=$(VIRTUAL_ENV)/bin/coveralls
BLACK=$(VIRTUAL_ENV)/bin/black
PRETTIER=node_modules/.bin/prettier
PYTHON_VERSION=3.9
PYTHON_WITH_VERSION=python$(PYTHON_VERSION)
DOCKER_IMAGE=hondash
SYSTEM_DEPENDENCIES_UBUNTU= \
$(PYTHON_WITH_VERSION) \
$(PYTHON_WITH_VERSION)-dev \
$(PYTHON_WITH_VERSION)-venv \
build-essential \
libsnappy-dev \
libusb-1.0-0 \
lsb-release \
node-gyp \
npm \
python3-pip
SYSTEM_DEPENDENCIES_RASPBIAN= \
libatlas-base-dev \
libsnappy-dev \
npm \
python3-pandas
SYSTEM_DEPENDENCIES_MACOS= \
snappy \
npm \
libusb
OS=$(shell lsb_release -si 2>/dev/null || uname)
system_dependencies:
ifeq ($(OS), Ubuntu)
apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES_UBUNTU)
else ifeq ($(OS), Debian)
apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES_RASPBIAN)
else ifeq ($(OS), Darwin)
brew install $(SYSTEM_DEPENDENCIES_MACOS)
endif
clean:
rm -rf $(VIRTUAL_ENV)
npm:
npm install
$(VIRTUAL_ENV): npm
$(PYTHON_WITH_VERSION) -m venv $(VIRTUAL_ENV)
$(PYTHON) -m pip install --upgrade pip setuptools wheel
$(PYTHON) -m pip install -r requirements.txt
virtualenv: $(VIRTUAL_ENV)
run: virtualenv
cp -n default_setup.json setup.json || true
$(PYTHON) -m http.server &
PYTHONPATH=src $(PYTHON) src/backend/main.py &
open http://localhost:8000/src/frontend/ &
run_rpi:
cp -n default_setup.json setup.json
sudo PYTHONPATH=src $(PYTHON) src/backend/main.py &
sleep 5
chromium-browser --use-gl=egl --kiosk --check-for-update-interval=604800 --incognito http://hondash.local/ &
dummy:
cp -n default_setup.json setup.json || true
PYTHONPATH=src $(PYTHON) src/backend/bench/dummy_backend.py &
open -a "Google Chrome" src/frontend/index.html
kill:
docker compose down -v || true
docker stop hondash_app_1 || true
docker stop hondash_nginx_1 || true
sudo pkill -f src/backend || true
sudo pkill -f http.server || true
test: lint
PYTHONPATH=src $(PYTEST) --cov src/ src/tests
@if [ -n "$$COVERALLS_REPO_TOKEN" ] && [ -f $(COVERALLS) ]; then $(COVERALLS); fi \
lint/isort-fix: virtualenv
$(ISORT) src
lint/isort-check: virtualenv
$(ISORT) --diff -c src
lint/flake8: virtualenv
$(FLAKE8) src
lint/black-fix: virtualenv
$(BLACK) --exclude $(VIRTUAL_ENV) src
lint/black-check: virtualenv
$(BLACK) --exclude $(VIRTUAL_ENV) src --check
lint/prettier-check: npm
$(PRETTIER) --check "src/frontend/**"
lint/prettier-fix: npm
$(PRETTIER) --write "src/frontend/**"
lint-fix: lint/isort-fix lint/black-fix lint/prettier-fix
lint: lint/isort-check lint/flake8 lint/black-check lint/prettier-check
coveralls: virtualenv
$(COVERALLS)
docker/build:
docker build --no-cache --tag=$(DOCKER_IMAGE) .
docker/pull:
docker pull $(DOCKER_IMAGE)
docker/run:
PY_FILE=src/backend/main.py docker compose up -d
@echo Access http://localhost:8080/frontend/ for dashboard
@echo Access http://localhost:8080/frontend/setup/ for setup
@echo Access http://localhost:8080/frontend/datalogs/ for datalogs
docker/demo:
PY_FILE=src/backend/bench/dummy_backend.py docker compose up -d --build -V --force-recreate app nginx
@echo Access http://localhost:8080/frontend/ for dashboard
@echo Access http://localhost:8080/frontend/setup/ for setup
@echo Access http://localhost:8080/frontend/datalogs/ for datalogs
docker/stop:
docker compose down --volume
docker/run/test:
docker run --env-file docker.env $(DOCKER_IMAGE) /bin/sh -c 'make test'
docker/run/shell:
docker run -it --rm $(DOCKER_IMAGE)
docker/run/lint:
docker run $(DOCKER_IMAGE) /bin/sh -c 'make lint'
sd-image/create:
sudo dd bs=1024 if=$(path) of=full_size_image.img
sd-image/shrink:
docker run --privileged=true --rm --volume $(shell pwd):/workdir mgomesborges/pishrink pishrink -v full_size_image.img shrinked_image.img
demo: virtualenv
cp -n default_setup.json setup.json || true
$(PYTHON) -m http.server &
PYTHONPATH=src $(PYTHON) src/backend/bench/dummy_backend.py &
open http://localhost:8000/src/frontend/ &