Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. SHELL := /bin/bash
  2. SETUP_SCRIPT := scripts/setup/setup.sh
  3. SETUP_BASH ?= $(or $(firstword $(wildcard /opt/homebrew/bin/bash /usr/local/bin/bash /opt/local/bin/bash)),$(shell command -v bash 2>/dev/null),bash)
  4. SETUP_OPTS ?=
  5. COLOR_RESET := \033[0m
  6. COLOR_BOLD := \033[1m
  7. COLOR_BLUE := \033[34m
  8. COLOR_GREEN := \033[32m
  9. COLOR_YELLOW := \033[33m
  10. ifeq ($(NO_COLOR),1)
  11. COLOR_RESET :=
  12. COLOR_BOLD :=
  13. COLOR_BLUE :=
  14. COLOR_GREEN :=
  15. COLOR_YELLOW :=
  16. endif
  17. .PHONY: help dev configure env-base env-storage env-server env-validate env-backup env-security-check env-base-rewrite env-storage-rewrite env base storage server validate backup security security-check base-rewrite storage-rewrite
  18. help:
  19. @printf "$(COLOR_BOLD)Interactive setup targets$(COLOR_RESET)\n"
  20. @printf " $(COLOR_GREEN)make dev$(COLOR_RESET) Bootstrap local dev+test+offline env with uv + bun\n"
  21. @printf " $(COLOR_GREEN)make env-base$(COLOR_RESET) Configure LLM, embedding, and reranker (run first)\n"
  22. @printf " $(COLOR_GREEN)make env-storage$(COLOR_RESET) Configure storage backends and databases\n"
  23. @printf " $(COLOR_GREEN)make env-server$(COLOR_RESET) Configure server, security, and SSL\n"
  24. @printf " $(COLOR_GREEN)make env-validate$(COLOR_RESET) Validate existing .env\n"
  25. @printf " $(COLOR_GREEN)make env-security-check$(COLOR_RESET) Audit existing .env for security risks\n"
  26. @printf " $(COLOR_GREEN)make env-backup$(COLOR_RESET) Backup current .env\n"
  27. @printf " $(COLOR_GREEN)make env-base-rewrite$(COLOR_RESET) Force-regenerate wizard-managed compose services during base setup\n"
  28. @printf " $(COLOR_GREEN)make env-storage-rewrite$(COLOR_RESET) Force-regenerate wizard-managed compose services during storage setup\n"
  29. @printf " $(COLOR_GREEN)make base$(COLOR_RESET) Short form of make env-base (all env prefix can be stripped)\n"
  30. @printf "\n"
  31. @printf "$(COLOR_BOLD)Typical workflow$(COLOR_RESET)\n"
  32. @printf " 1. make dev # install backend/test deps and build frontend\n"
  33. @printf " 2. make env-base # set LLM/embedding/reranker\n"
  34. @printf " 3. make env-storage # set storage backends (optional)\n"
  35. @printf " 4. make env-server # set port/security/SSL (optional)\n\n"
  36. @printf "$(COLOR_BOLD)Examples$(COLOR_RESET)\n"
  37. @printf " make dev\n"
  38. @printf " make env-base\n"
  39. @printf " make env-storage SETUP_OPTS=--debug\n"
  40. @printf " make env-server\n\n"
  41. @printf " make env-storage-rewrite\n\n"
  42. @printf " make env-security-check\n\n"
  43. @printf "$(COLOR_BOLD)Compose Output$(COLOR_RESET)\n"
  44. @printf " Bundled service images are defined in scripts/setup/templates/*.yml.\n"
  45. @printf " Compose file output: docker-compose.final.yml\n"
  46. dev:
  47. @if ! command -v uv >/dev/null 2>&1; then \
  48. printf "$(COLOR_YELLOW)uv is required for make dev.$(COLOR_RESET)\n"; \
  49. printf "Install uv first: https://docs.astral.sh/uv/getting-started/installation/\n"; \
  50. printf "Unix/macOS: curl -LsSf https://astral.sh/uv/install.sh | sh\n"; \
  51. printf "Windows: powershell -c \"irm https://astral.sh/uv/install.ps1 | iex\"\n"; \
  52. exit 1; \
  53. fi
  54. @if ! command -v bun >/dev/null 2>&1; then \
  55. printf "$(COLOR_YELLOW)bun is required for make dev.$(COLOR_RESET)\n"; \
  56. printf "Install Bun first: https://bun.sh/docs/installation\n"; \
  57. printf "macOS/Linux: curl -fsSL https://bun.sh/install | bash\n"; \
  58. printf "Windows: powershell -c \"irm bun.sh/install.ps1 | iex\"\n"; \
  59. exit 1; \
  60. fi
  61. @printf "$(COLOR_BLUE)Syncing backend and test dependencies with uv...$(COLOR_RESET)\n"
  62. @uv sync --extra test --extra offline
  63. @printf "$(COLOR_BLUE)Installing frontend dependencies with Bun...$(COLOR_RESET)\n"
  64. @cd lightrag_webui && bun install --frozen-lockfile
  65. @printf "$(COLOR_BLUE)Building frontend assets...$(COLOR_RESET)\n"
  66. @cd lightrag_webui && bun run build
  67. @printf "$(COLOR_GREEN)Development environment is ready.$(COLOR_RESET)\n"
  68. @printf "Next steps:\n"
  69. @printf " source .venv/bin/activate\n"
  70. @printf " make env-base\n"
  71. @printf " lightrag-server\n"
  72. env-base env base configure:
  73. @$(SETUP_BASH) $(SETUP_SCRIPT) --base $(SETUP_OPTS)
  74. env-storage storage:
  75. @$(SETUP_BASH) $(SETUP_SCRIPT) --storage $(SETUP_OPTS)
  76. env-base-rewrite base-rewrite:
  77. @$(SETUP_BASH) $(SETUP_SCRIPT) --base --rewrite-compose $(SETUP_OPTS)
  78. env-storage-rewrite storage-rewrite:
  79. @$(SETUP_BASH) $(SETUP_SCRIPT) --storage --rewrite-compose $(SETUP_OPTS)
  80. env-server server:
  81. @$(SETUP_BASH) $(SETUP_SCRIPT) --server $(SETUP_OPTS)
  82. env-validate validate:
  83. @$(SETUP_BASH) $(SETUP_SCRIPT) --validate $(SETUP_OPTS)
  84. env-security-check security security-check:
  85. @$(SETUP_BASH) $(SETUP_SCRIPT) --security-check $(SETUP_OPTS)
  86. env-backup backup:
  87. @$(SETUP_BASH) $(SETUP_SCRIPT) --backup $(SETUP_OPTS)