-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
155 lines (110 loc) · 3.74 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
154
# Authors:
# - RJ Sheperd ([email protected])
# - George Silva ([email protected])
USER_ID = $(shell id -u)
# User Systemd Service (see: ~/.config/systemd/user/planscape.service)
SERVICE=planscape
# Directory which NGINX serves up for planscape
PUBLIC_WWW_DIR=/var/www/html/planscape/
# Directory which NGINX serves up for storybook
STORYBOOK_WWW_DIR=/var/www/html/storybook/
# Systemd User Control
SYS_CTL=systemctl --user
TAG=main
VERSION="$$(date '+%Y.%m.%d')-$$(git log --abbrev=10 --format=%h | head -1)"
help:
@echo 'Available commands:'
@echo ''
@echo 'build ................................ Builds image'
@echo 'run .................................. Runs the webserver'
@echo 'test ................................. Runs all tests except integration'
@echo 'lock ................................. Locks the versions of dependencies.'
@echo ''
checkout:
set -e; \
git fetch origin; \
git switch main; \
git pull origin main; \
git checkout $(TAG); \
echo "Completed git checkout"
taggit:
set -e; \
git checkout main; \
git pull origin main; \
git tag -a $(VERSION) -m $(VERSION); \
git push origin --tags; \
echo "Completed taggit"
install-dependencies-frontend:
cd src/interface && npm install
compile-angular:
cd src/interface && npm run build -- --configuration production --output-path=./dist/out
build-storybook:
cd src/interface && npm run build-storybook
deploy-frontend: install-dependencies-frontend compile-angular
cp -r ./src/interface/dist/out/** ${PUBLIC_WWW_DIR}
deploy-storybook: install-dependencies-frontend build-storybook
cp -r ./src/interface/storybook-static/** ${STORYBOOK_WWW_DIR}
cypress-test:
cd src/interface && npm run cypress:run
mypy:
mypy . --strict --ignore-missing-imports | grep src/ | wc -l
migrate:
cd src/planscape && python3 manage.py migrate --no-input
cd src/planscape && python3 manage.py collectstatic --no-input
cd src/planscape && python3 manage.py install_layers
load-conditions:
cd src/planscape && python3 manage.py load_conditions
load-metrics:
cd src/planscape && python3 manage.py load_metrics
load-rasters:
cd src/planscape && python3 manage.py load_rasters
install-dependencies-backend:
pip install poetry setuptools && python3 -m poetry export -f requirements.txt --with dev --without-hashes --output requirements.txt && pip install -r requirements.txt
deploy-backend: install-dependencies-backend migrate restart
deploy-all: deploy-backend deploy-frontend
start-celery:
${SYS_CTL} start celery-* --all
stop-celery:
${SYS_CTL} stop celery-* --all
status-celery:
${SYS_CTL} status celery-* --all
start:
${SYS_CTL} start ${SERVICE}
stop:
${SYS_CTL} stop ${SERVICE}
status:
${SYS_CTL} status ${SERVICE}
reload:
${SYS_CTL} daemon-reload
restart: reload stop stop-celery start start-celery
nginx-restart:
sudo service nginx restart
load-restrictions:
cd src/planscape && sh bin/load_restrictions.sh
test-scenarios:
cd src/planscape && python3 manage.py test_scenarios
SERID=$(shell id -u)
GROUPID=$(shell id -g)
TEST=.
APP_LABEL=
DOCKER_BUILDKIT=1
docker-clean:
docker compose down --volumes
docker container prune -f
docker-hard-clean: docker-clean
docker image prune -f
docker-build:
docker compose build
docker-test:
./src/planscape/bin/run.sh python manage.py test $(TEST)
docker-run: docker-build
docker compose up
docker-shell:
./src/planscape/bin/run.sh bash
docker-makemigrations:
./src/planscape/bin/run.sh python manage.py makemigrations --no-header $(APP_LABEL) $(OPTIONS)
find . -type d -name migrations -exec sudo chown -R $(USER): {} +
docker-migrate:
./src/planscape/bin/run.sh python manage.py migrate
./src/planscape/bin/run.sh python manage.py install_layers
.PHONY: all docker-build docker-test docker-run docker-shell docker-makemigrations docker-migrate