diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..8b621e1b --- /dev/null +++ b/Makefile @@ -0,0 +1,54 @@ +.PHONY: help setup db-up db-down migrate bootstrap dev shell clean + +help: ## Show this help message + @echo 'Usage: make [target]' + @echo '' + @echo 'Available targets:' + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' + +setup: db-up migrate bootstrap ## Complete setup: start database, run migrations, and bootstrap data + @echo "✓ Setup complete! You do not need to run this again; Run 'make dev' to start the development server." + +db-up: ## Start PostgreSQL database using Docker Compose + @echo "Starting PostgreSQL database..." + @docker compose up -d -f docker-compose.dev.yml + @echo "Waiting for database to be ready..." + @sleep 3 + @echo "✓ Database is running" + +db-down: ## Stop PostgreSQL database + @echo "Stopping PostgreSQL database..." + @docker compose down + +migrate: ## Run database migrations + @echo "Running migrations..." + @uv run python manage.py migrate + @echo "✓ Migrations complete" + +bootstrap: ## Bootstrap initial data (anonymous user, packages, models) + @echo "Bootstrapping initial data..." + @echo "This will take a bit ⏱️. Get yourself some coffe..." + @uv run python manage.py bootstrap + @echo "✓ Bootstrap complete" + @echo "" + @echo "Default admin credentials:" + @echo " Username: admin" + @echo " Email: admin@envipath.com" + @echo " Password: SuperSafe" + +dev: db-up + @uv run python manage.py runserver + +shell: ## Open Django shell + @uv run python manage.py shell + +clean: ## Remove database and volumes (WARNING: destroys all data) + @echo "WARNING: This will delete all database data!" + @read -p "Are you sure? [y/N] " -n 1 -r; \ + echo; \ + if [[ $$REPLY =~ ^[Yy]$$ ]]; then \ + docker compose down -v; \ + echo "✓ Cleaned"; \ + else \ + echo "Cancelled"; \ + fi diff --git a/README.md b/README.md index bce932e3..49dd520a 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,12 @@ These instructions will guide you through setting up the project for local devel ### Prerequisites - Python 3.11 or later -- [uv](https://github.com/astral-sh/uv) - A fast Python package installer and resolver. -- **Docker and Docker Compose** - Required for running the PostgreSQL database. +- [uv](https://github.com/astral-sh/uv) - Python package manager +- **Docker and Docker Compose** - Required for running PostgreSQL database - Git -> **Note:** This application requires PostgreSQL, which uses `ArrayField`. Docker is the recommended way to run PostgreSQL locally. +> **Note:** This application requires PostgreSQL (uses `ArrayField`). Docker is the easiest way to run PostgreSQL locally. + ### 1. Install Dependencies