From 1cee37546707dcd9056e183045d36e525c8082cb Mon Sep 17 00:00:00 2001 From: Yury Kossakovsky Date: Tue, 9 Dec 2025 22:18:58 -0700 Subject: [PATCH] feat: add makefile for common project commands --- CLAUDE.md | 54 ++++++++++++--------------------------------------- Makefile | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 32 ++++++++++++++++++++++++++---- 3 files changed, 98 insertions(+), 46 deletions(-) create mode 100644 Makefile diff --git a/CLAUDE.md b/CLAUDE.md index 371dc95..26f0553 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -15,6 +15,7 @@ This is **n8n-install**, a Docker Compose-based installer that provides a compre ### Key Files +- `Makefile`: Common commands (install, update, logs, etc.) - `docker-compose.yml`: Service definitions with profiles - `Caddyfile`: Reverse proxy configuration with automatic HTTPS - `.env`: Generated secrets and configuration (from `.env.example`) @@ -25,54 +26,23 @@ This is **n8n-install**, a Docker Compose-based installer that provides a compre ## Common Development Commands -### Installation and Updates +### Makefile Commands ```bash -# Full installation (run from project root) -sudo bash ./scripts/install.sh +make install # Full installation +make update # Update system and services +make clean # Remove unused Docker resources -# Update to latest versions and pull new images -sudo bash ./scripts/update.sh +make logs # View logs (all services) +make logs s= # View logs for specific service +make status # Show container status +make monitor # Live CPU/memory monitoring +make restarts # Show restart count per container -# Re-run service selection wizard (for adding/removing services) -sudo bash ./scripts/04_wizard.sh +make switch-beta # Switch to beta (develop branch) +make switch-stable # Switch to stable (main branch) ``` -### Docker Compose Operations - -```bash -# Start all enabled profile services -docker compose -p localai up -d - -# View logs for a specific service -docker compose -p localai logs -f --tail=200 | cat - -# Recreate a single service (e.g., after config changes) -docker compose -p localai up -d --no-deps --force-recreate - -# Stop all services -docker compose -p localai down - -# Remove unused Docker resources -sudo bash ./scripts/docker_cleanup.sh -``` - -### Development and Testing - -```bash -# Regenerate secrets after modifying .env.example -bash ./scripts/03_generate_secrets.sh - -# Check current active profiles -grep COMPOSE_PROFILES .env - -# View Caddy logs for reverse proxy issues -docker compose -p localai logs -f caddy - -# Test n8n worker scaling -# Edit N8N_WORKER_COUNT in .env, then: -docker compose -p localai up -d --scale n8n-worker= -``` ## Adding a New Service diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3aae5c6 --- /dev/null +++ b/Makefile @@ -0,0 +1,58 @@ +.PHONY: help install update clean logs status monitor restarts switch-beta switch-stable + +PROJECT_NAME := localai + +help: + @echo "n8n-install - Available commands:" + @echo "" + @echo " make install Full installation" + @echo " make update Update system and services" + @echo " make clean Remove unused Docker resources" + @echo "" + @echo " make logs View logs (all services)" + @echo " make logs s= View logs for specific service" + @echo " make status Show container status" + @echo " make monitor Live CPU/memory monitoring" + @echo " make restarts Show restart count per container" + @echo "" + @echo " make switch-beta Switch to beta (develop branch)" + @echo " make switch-stable Switch to stable (main branch)" + +install: + sudo bash ./scripts/install.sh + +update: + sudo bash ./scripts/update.sh + +clean: + sudo bash ./scripts/docker_cleanup.sh + +logs: +ifdef s + docker compose -p $(PROJECT_NAME) logs -f --tail=200 $(s) +else + docker compose -p $(PROJECT_NAME) logs -f --tail=100 +endif + +status: + docker compose -p $(PROJECT_NAME) ps + +monitor: + docker stats + +restarts: + @docker ps -q | while read id; do \ + name=$$(docker inspect --format '{{.Name}}' $$id | sed 's/^\/\(.*\)/\1/'); \ + restarts=$$(docker inspect --format '{{.RestartCount}}' $$id); \ + echo "$$name restarted $$restarts times"; \ + done + +switch-beta: + git restore docker-compose.yml + git checkout develop + sudo bash ./scripts/update.sh + +switch-stable: + git restore docker-compose.yml + git checkout main + sudo bash ./scripts/update.sh diff --git a/README.md b/README.md index f05cfaa..54fa117 100644 --- a/README.md +++ b/README.md @@ -218,10 +218,10 @@ n8n v2.0 uses external task runners to execute JavaScript and Python code in Cod ## Upgrading -To update all components (n8n, Open WebUI, etc.) to their latest versions and incorporate the newest changes from this installer project, use the update script from the project root: +To update all components (n8n, Open WebUI, etc.) to their latest versions and incorporate the newest changes from this installer project: ```bash -sudo bash ./scripts/update.sh +make update ``` This script will: @@ -234,14 +234,38 @@ This script will: ## Cleaning up Docker -If you need to free up disk space, you can run the Docker cleanup script. This script removes all unused Docker containers, images, and volumes. +If you need to free up disk space, you can run the Docker cleanup command. This removes all unused Docker containers, images, and volumes. ```bash -sudo bash ./scripts/docker_cleanup.sh +make clean ``` This can be useful for removing old images and freeing up space, but be aware that it will remove all unused data. +## Quick Commands (Makefile) + +The project includes a Makefile for simplified command execution: + +| Command | Description | +|---------|-------------| +| `make install` | Full installation | +| `make update` | Update system and services | +| `make clean` | Remove unused Docker resources | +| `make logs` | View logs (all services) | +| `make logs s=n8n` | View logs for specific service | +| `make status` | Show container status | +| `make monitor` | Live CPU/memory monitoring | +| `make restarts` | Show restart count per container | + +### Switch Versions + +| Command | Description | +|---------|-------------| +| `make switch-beta` | Switch to beta (develop branch) | +| `make switch-stable` | Switch to stable (main branch) | + +Run `make help` for the full list of available commands. + ## Important Links - Based on a project by [coleam00](https://github.com/coleam00/local-ai-packaged)