-
-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (67 loc) · 2.91 KB
/
Makefile
File metadata and controls
89 lines (67 loc) · 2.91 KB
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
default:
@echo "Call a specific subcommand:"
@echo
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null\
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}'\
| sort\
| egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
@echo
@exit 1
.state/docker-build-web: Dockerfile requirements-app.txt requirements-dev.txt
# Build our web container for this project.
docker compose build --build-arg USER_ID=$(shell id -u) --build-arg GROUP_ID=$(shell id -g) --force-rm web
# Collect static assets
docker compose run --rm web python manage.py collectstatic --noinput --clear
# Create createcachetable
docker compose run --rm web python manage.py createcachetable
# Mark the state so we don't rebuild this needlessly.
mkdir -p .state
touch .state/docker-build-web
.state/db-migrated:
make migrate
mkdir -p .state && touch .state/db-migrated
.state/db-initialized: .state/docker-build-web .state/db-migrated
# Do anything you might need to after the DB is built/migrated here (like fixtures)
# Mark the state so we don't reload after first launch.
mkdir -p .state
touch .state/db-initialized
serve: .state/db-initialized
docker compose up --remove-orphans -d
shell: .state/db-initialized
docker compose run --rm web /bin/bash
dbshell: .state/db-initialized
docker compose exec postgres psql -U pyladiescon pyladiescon
manage: .state/db-initialized
# Run Django manage to accept arbitrary arguments
docker compose run --rm web ./manage.py $(filter-out $@,$(MAKECMDGOALS))
migrations: .state/db-initialized
# Run Django makemigrations
docker compose run --rm web ./manage.py makemigrations
migrate: .state/docker-build-web
# Run Django migrate
docker compose run --rm web ./manage.py migrate $(filter-out $@,$(MAKECMDGOALS))
lint: .state/docker-build-web
docker compose run --rm web isort --check-only .
docker compose run --rm web black --check .
docker compose run --rm web djlint . --check
docker compose run --rm web djlint . --lint
docker compose run --rm web flake8
docker compose run --rm web python manage.py makemigrations --check --settings=portal.settings
reformat: .state/docker-build-web
docker compose run --rm web isort .
docker compose run --rm web black .
docker compose run --rm web djlint . --reformat
test: .state/docker-build-web
docker compose run --rm web pytest --cov --reuse-db --no-migrations --cov-fail-under=100 --cov-report html --cov-report term
check: test lint
create_translations: .state/docker-build-web
docker compose run --rm web ./manage.py makemessages --locale $(LANG)
compile_translations: .state/docker-build-web
docker compose run --rm web ./manage.py compilemessages
clean:
docker compose down -v
rm -rf staticroot
rm -f .state/docker-build-web
rm -f .state/db-initialized
rm -f .state/db-migrated
.PHONY: default serve shell dbshell manage migrations migrate lint reformat test check create_translations compile_translations clean