forked from MahjongRepository/mahjong-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (48 loc) · 1.84 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
up:
docker compose up
down:
docker compose stop
logs:
docker compose logs -f
shell:
docker compose run --user=root --rm web sh
build-docker:
docker compose build
initial-data:
docker compose run -u `id -u` --rm web python manage.py flush --noinput
docker compose run -u `id -u` --rm web python manage.py migrate --noinput
docker compose run -u `id -u` --rm web python manage.py initial_data
test:
docker compose run -u `id -u` --rm web python manage.py test --noinput
# usage example "make db-restore dump=~/Downloads/dump.sql"
db-restore:
docker compose up --detach db
docker compose run --rm db sh -c \
'PGPASSWORD=$$POSTGRES_PASSWORD dropdb -U $$POSTGRES_USER -h $$POSTGRES_HOST $$POSTGRES_DB --if-exists' \
--env-file .envs/.local
docker compose run --rm db sh -c \
'PGPASSWORD=$$POSTGRES_PASSWORD createdb -U $$POSTGRES_USER -h $$POSTGRES_HOST $$POSTGRES_DB' \
--env-file .envs/.local
docker compose run \
-v $(dump):/tmp/dump.sql \
--rm db sh -c 'PGPASSWORD=$$POSTGRES_PASSWORD psql -U $$POSTGRES_USER -h $$POSTGRES_HOST $$POSTGRES_DB < /tmp/dump.sql' \
--env-file .envs/.local
release-docker-image:
docker buildx build --push \
--build-arg mode=production \
--tag ghcr.io/mahjongrepository/mahjong-portal:latest \
--tag ghcr.io/mahjongrepository/mahjong-portal:$(shell git show-ref refs/heads/master --hash=7) \
--file ./docker/django/Dockerfile .
#### Code formatters and linters ####
lint: lint-isort lint-python-code-style lint-flake8
format: format-isort format-python-code
lint-python-code-style:
docker compose run -u `id -u` --rm web black --check .
lint-isort:
docker compose run -u `id -u` --rm web isort --check-only .
lint-flake8:
docker compose run -u `id -u` --rm web flake8 .
format-python-code:
docker compose run -u `id -u` --rm web black .
format-isort:
docker compose run -u `id -u` --rm web isort .