brewery-website/Makefile
2024-06-03 12:56:03 -04:00

48 lines
1.3 KiB
Makefile

VENV := .env
BIN := $(VENV)/bin
PYTHON := $(BIN)/python
SHELL := /bin/bash
MKFILEDIR := $(abspath $(lastword $(MAKEFILE_LIST)))
SOURCEDIR := $(notdir $(patsubst %/,%,$(dir $(MKFILEDIR))))
DOT_DIRS := $(dir $(wildcard $(SOURCEDIR)/*/.*))
PYFILES := $(filter-out .%,$(shell find $(SOURCEDIR) -name '*.py'))
venv/touchfile: requirements.txt
test -d $(VENV) || virtualenv $(VENV)
touch $(VENV)/touchfile
.PHONY: venv
venv: $(VENV)/touchfile ## Make a new virtual environment
python3 -m venv $(VENV) && source $(BIN)/activate
.PHONY: install
install: venv ## Make venv and install requirements
$(BIN)/pip install --upgrade -r requirements.txt
migrate: ## Make and run migrations
$(PYTHON) manage.py makemigrations
$(PYTHON) manage.py migrate
.PHONY: test
test: ## Run tests
$(PYTHON) manage.py test application --verbosity=0 --parallel --failfast
start: install migrate run
pull:
git pull origin master
deploy: $(PYFILES)
sudo systemctl restart gunicorn.service gunicorn.socket
update: pull install deploy
clean:
find -iname "*.pyc" -delete
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}'
.PHONY: clean clean pull deploy update