From f76f5cec75a647e7f7fb62a89af1fc9b01551bdc Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 5 Jun 2024 11:16:52 -0400 Subject: [PATCH] Fancier makefile. --- Makefile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 2e7ce7a..00c9186 100644 --- a/Makefile +++ b/Makefile @@ -9,16 +9,22 @@ IGNORE = .git .env PYFILES := $(filter-out $(IGNORE),$(call rwildcard,.,*.py)) HTMLFILES := $(filter-out $(IGNORE),$(call rwildcard,.,*.html)) -$(VENV)/touchfile: requirements.txt +$(VENV)/.install: requirements.txt test -d $(VENV) || python3 -m venv $(VENV) $(BIN)/pip install --upgrade -r requirements.txt - touch $(VENV)/touchfile + touch $(VENV)/.install -.PHONY: migrate -migrate: $(PYFILES) ## Make and run migrations +$(VENV)/.migrate: $(PYFILES) $(VENV)/.install $(PYTHON) manage.py makemigrations $(PYTHON) manage.py migrate $(PYTHON) manage.py collectstatic --noinput + touch $(VENV)/.migrate + +$(VENV)/.start: $(HTMLFILES) $(VENV)/.migrate + sudo systemctl restart gunicorn.service gunicorn.socket + touch $(VENV)/.start +.PHONY: migrate +migrate: $(VENV)/.migrate ## Make and run migrations .PHONY: test test: ## Run tests @@ -29,11 +35,10 @@ pull: git pull origin master .PHONY: start -start: $(HTMLFILES) $(PYFILES) ## Restart gunicorn - sudo systemctl restart gunicorn.service gunicorn.socket +start: $(VENV)/.start ## Restart gunicorn .PHONY: update -update: pull $(VENV)/touchfile migrate start ## Pull latest from remote and restart +update: pull $(VENV)/.install $(VENV)/.migrate $(VENV)/.start ## Pull latest from remote and restart .PHONY: backup backup: ## Backup database to json file. @@ -49,3 +54,4 @@ clean: help: ## Self-documented Makefile @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' +