-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
155 lines (119 loc) · 3.64 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
155
# default target
.DEFAULT_GOAL := run-server
# Variables commands
POETRY_RUN := poetry run
DJANGO_RUN := $(POETRY_RUN) python -m core.manage
PRE_COMMIT_CMD := $(POETRY_RUN) pre-commit
DOCKER_COMPOSE := docker compose
CARGO_INSTALL := cargo install
# Variables paths
DOCS_PATH := docs
PROJECT_SETTINGS_TEMPLATE_PATH := core/project/settings/templates/settings.dev.py
DOCKER_COMPOSE_DEV_PATH := docker-compose.dev.yaml
# Commands
.PHONY: install
install:
poetry install
.PHONY: install-pre-commit
install-pre-commit:
$(PRE_COMMIT_CMD) uninstall && $(PRE_COMMIT_CMD) install
.PHONY: lint
lint:
$(PRE_COMMIT_CMD) run --all-files
.PHONY: runserver
runserver:
$(DJANGO_RUN) runserver
.PHONY: migrate
migrate:
$(DJANGO_RUN) migrate
.PHONY: migrations
migrations:
$(DJANGO_RUN) makemigrations
.PHONY: superuser
superuser:
$(DJANGO_RUN) createsuperuser
.PHONY: app
app:
$(eval name=$(filter-out $@,$(MAKECMDGOALS)))
$(DJANGO_RUN) startapp $(name)
mv $(name) core/
%:
@:
.PHONY: local-settings
local-settings:
if [ ! -f "local/settings.dev.py" ]; then mkdir local && cp $(PROJECT_SETTINGS_TEMPLATE_PATH) local/settings.dev.py; fi
.PHONY: update
update: install migrate install-pre-commit;
.PHONY: up-dependencies-only
up-dependencies-only:
test -f .env || touch .env
$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_DEV_PATH) up --force-recreate db
.PHONY: collectstatic
collectstatic:
$(DJANGO_RUN) collectstatic
shell:
$(DJANGO_RUN) shell
.PHONY: api-version
api-version:
$(DJANGO_RUN) shell -c "from django.conf import settings; print(settings.API_VERSION)"
.PHONY: image/build
image/build:
@API_VERSION=$$($(DJANGO_RUN) shell -c "from django.conf import settings; print(settings.API_VERSION)") && \
docker build -t hotmix:$$API_VERSION -t hotmix:latest .
.PHONY: docker/build
docker/build:
$(DOCKER_COMPOSE) build
.PHONY: docker/dev/up
docker/dev/up:
$(DOCKER_COMPOSE) -f docker-compose.dev.yaml up -d
.PHONY: build-up
build-up:build up;
.PHONY: docker/down
docker/down:
$(DOCKER_COMPOSE) down
.PHONY: install/cargo
install/cargo:
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
.PHONY: install/mdbook
install/mdbook:
$(CARGO_INSTALL) mdbook
.PHONY: docs/build
docs/build:
cd $(DOCS_PATH) && mdbook build
.PHONY: docs/serve
docs/serve:
cd $(DOCS_PATH) && mdbook serve --open
# Provide quick help for common Makefile targets.
.PHONY: help
help:
@echo "run 'make' to run the the django server"
@echo ""
@echo "or 'make <target>' where <target> is one of the following:"
@echo ""
@echo " install Install the project dependencies"
@echo " install-pre-commit Install pre-commit hooks"
@echo " lint Run pre-commit hooks"
@echo ""
@echo " run-server Run the django server"
@echo " migrate Apply migrations"
@echo " migrations Create migrations"
@echo " superuser Create superuser"
@echo " app <name> Create a new app"
@echo " shell Run the django shell"
@echo ""
@echo " local-settings Create local settings file"
@echo " update Install dependencies, apply migrations and install pre-commit hooks"
@echo " up-dependencies-only Up only the dependencies"
@echo " collectstatic Collect static files"
@echo ""
@echo " docker/build Build the docker images"
@echo " docker/up Up the docker containers"
@echo " build-up Build and up the docker containers"
@echo " docker/down Down the docker containers"
@echo ""
@echo " install/cargo Install cargo"
@echo " install/mdbook Install mdbook"
@echo " docs/build Build the documentation"
@echo " docs/serve Serve the documentation"
@echo ""
@echo "For more information, see the README.md file."