From abbc3c3d1dcf250aef2a8cab33726e18f21e6870 Mon Sep 17 00:00:00 2001 From: codex_a Date: Sun, 1 Mar 2026 14:24:13 +0000 Subject: [PATCH] feat: add Makefile for Docker and Django ops Covers: - Docker: build, up, run, down, restart, logs, ps, bash, psql - Django: migrate, makemigrations, showmigrations, createsuperuser, collectstatic, shell, dbshell - Tailwind: install, build, watch - Testing: pytest unit and E2E targets - Custom commands: seed, check-content, purge-comments Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Makefile | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e0190e4 --- /dev/null +++ b/Makefile @@ -0,0 +1,123 @@ +DC = docker compose +WEB = $(DC) exec web +MANAGE = $(WEB) python manage.py + +.DEFAULT_GOAL := help + +# ── Help ────────────────────────────────────────────────────────────────────── + +.PHONY: help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ + | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-28s\033[0m %s\n", $$1, $$2}' \ + | sort + +# ── Docker ──────────────────────────────────────────────────────────────────── + +.PHONY: build +build: ## Build / rebuild images + $(DC) build + +.PHONY: up +up: ## Start services (detached) + $(DC) up -d + +.PHONY: run +run: ## Start services in foreground (with logs) + $(DC) up + +.PHONY: down +down: ## Stop and remove containers + $(DC) down + +.PHONY: restart +restart: ## Restart all services + $(DC) restart + +.PHONY: logs +logs: ## Tail logs for all services (Ctrl-C to stop) + $(DC) logs -f + +.PHONY: logs-web +logs-web: ## Tail web service logs + $(DC) logs -f web + +.PHONY: ps +ps: ## Show running containers + $(DC) ps + +# ── Django ──────────────────────────────────────────────────────────────────── + +.PHONY: migrate +migrate: ## Apply database migrations + $(MANAGE) migrate --noinput + +.PHONY: makemigrations +makemigrations: ## Create new migrations (pass app= to target an app) + $(MANAGE) makemigrations $(app) + +.PHONY: showmigrations +showmigrations: ## List all migrations and their status + $(MANAGE) showmigrations + +.PHONY: createsuperuser +createsuperuser: ## Create a Django superuser interactively + $(MANAGE) createsuperuser + +.PHONY: collectstatic +collectstatic: ## Collect static files + $(MANAGE) collectstatic --noinput + +.PHONY: shell +shell: ## Open a Django shell (inside the web container) + $(MANAGE) shell + +.PHONY: dbshell +dbshell: ## Open a Django database shell + $(MANAGE) dbshell + +.PHONY: bash +bash: ## Open a bash shell inside the web container + $(WEB) bash + +.PHONY: psql +psql: ## Open a psql shell in the db container + $(DC) exec db psql -U nohype -d nohype + +# ── Tailwind ────────────────────────────────────────────────────────────────── + +.PHONY: tailwind-install +tailwind-install: ## Install Tailwind npm dependencies + $(MANAGE) tailwind install --no-input + +.PHONY: tailwind-build +tailwind-build: ## Build Tailwind CSS + $(MANAGE) tailwind build + +.PHONY: tailwind-watch +tailwind-watch: ## Watch and rebuild Tailwind CSS on changes + $(MANAGE) tailwind start + +# ── Testing ─────────────────────────────────────────────────────────────────── + +.PHONY: test +test: ## Run unit/integration tests with pytest + $(DC) exec web pytest $(args) + +.PHONY: test-e2e +test-e2e: ## Run Playwright E2E tests + $(DC) exec web pytest e2e/ $(args) + +# ── Custom management commands ──────────────────────────────────────────────── + +.PHONY: seed +seed: ## Seed deterministic E2E content + $(MANAGE) seed_e2e_content + +.PHONY: check-content +check-content: ## Validate live content integrity + $(MANAGE) check_content_integrity + +.PHONY: purge-comments +purge-comments: ## Purge old comment personal data (pass months=N to override default 24) + $(MANAGE) purge_old_comment_data $(if $(months),--months $(months),)