-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
100 lines (72 loc) · 3.41 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
# This Makefile is based on the Makefile defined in the Python Best Practices repository:
# https://git.datapunt.amsterdam.nl/Datapunt/python-best-practices/blob/master/dependency_management/
#
# VERSION = 2020.01.29
.PHONY: app manifests
dc = docker compose
run = $(dc) run --rm
manage = $(run) dev python manage.py
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
pip-tools:
pip install pip-tools
install: pip-tools ## Install requirements and sync venv with expected state as defined in requirements.txt
pip-sync requirements.txt requirements_dev.txt
requirements: pip-tools ## Upgrade requirements (in requirements.in) to latest versions and compile requirements.txt
## The --allow-unsafe flag should be used and will become the default behaviour of pip-compile in the future
## https://stackoverflow.com/questions/58843905
pip-compile --upgrade --output-file requirements.txt --allow-unsafe requirements.in
pip-compile --upgrade --output-file requirements_dev.txt --allow-unsafe requirements_dev.in
upgrade: requirements install ## Run 'requirements' and 'install' targets
migrations: ## Make migrations
$(manage) makemigrations
migrate: ## Migrate
$(manage) migrate
urls: ## Show available URLs
$(manage) show_urls
build: ## Build docker image
$(dc) build
push: ## Push docker image to registry
$(dc) push
app: ## Run app
$(run) --service-ports app
bash: ## Run the container and start bash
$(run) dev bash
shell: ## Run shell_plus and print sql
$(manage) shell
dev: migrate ## Run the development app (and run extra migrations first)
$(run) --service-ports dev
test: ## Execute tests
$(run) test pytest /tests -m 'not migration' $(ARGS)
superuser: ## Create a new superuser
$(manage) createsuperuser --noinput
clean: ## Clean docker stuff
$(dc) down -v --remove-orphans
env: ## Print current env
env | sort
load_dump:
PGPASSWORD=insecure psql "host=localhost dbname=meetbouten user=meetbouten" < local/meetbouten.dump
test_data: migrate
$(manage) generate_test_data --num 100
test_cor_load: migrate
$(manage) generate_cor_load --num 10
trivy: ## Detect image vulnerabilities
$(dc) build --no-cache app
trivy image --ignore-unfixed localhost:5000/opdrachten/meetbouten:latest
diff:
@python3 ./deploy/diff.py
lintfix: ## Execute lint fixes
$(run) test black /src/$(APP) /tests/$(APP)
$(run) test autoflake /src --recursive --in-place --remove-unused-variables --remove-all-unused-imports --quiet
$(run) test isort /src/$(APP) /tests/$(APP)
lint: ## Execute lint checks
$(run) test autoflake /src --check --recursive --quiet
$(run) test isort --diff --check /src/$(APP) /tests/$(APP)
# Initiate migrations and superuser on kubernetes pod
# Function called "fn", which references the Django commands $1
fn = kubectl exec -it deployment/app -- /bin/bash -c "python manage.py $(1)"
init_kubectl:
$(call fn, migrate)
$(call fn, createsuperuser --noinput)
pgdump:
$(manage) pgdump