|
| 1 | +.PHONY: help dev prod build test clean deploy |
| 2 | + |
| 3 | +# Default target |
| 4 | +help: |
| 5 | + @echo "CodeIntel - Development Commands" |
| 6 | + @echo "" |
| 7 | + @echo "Local Development:" |
| 8 | + @echo " make dev - Start all services with hot reload" |
| 9 | + @echo " make prod - Start production-like environment" |
| 10 | + @echo " make build - Build Docker images" |
| 11 | + @echo " make stop - Stop all services" |
| 12 | + @echo " make clean - Stop and remove all containers/volumes" |
| 13 | + @echo " make logs - View all logs" |
| 14 | + @echo "" |
| 15 | + @echo "Testing:" |
| 16 | + @echo " make test - Run backend tests" |
| 17 | + @echo " make test-watch - Run tests in watch mode" |
| 18 | + @echo " make coverage - Run tests with coverage report" |
| 19 | + @echo "" |
| 20 | + @echo "Deployment:" |
| 21 | + @echo " make deploy-backend - Deploy backend to Railway" |
| 22 | + @echo " make deploy-frontend - Deploy frontend to Vercel" |
| 23 | + @echo " make deploy-all - Deploy both backend and frontend" |
| 24 | + |
| 25 | +# Development with hot reload |
| 26 | +dev: |
| 27 | + docker compose -f docker-compose.dev.yml up -d |
| 28 | + @echo "" |
| 29 | + @echo "✅ Development environment started!" |
| 30 | + @echo " Backend: http://localhost:8000" |
| 31 | + @echo " Docs: http://localhost:8000/docs" |
| 32 | + @echo " Frontend: http://localhost:3000" |
| 33 | + @echo " Redis: localhost:6379" |
| 34 | + @echo "" |
| 35 | + @echo "View logs: make logs" |
| 36 | + |
| 37 | +# Production-like environment |
| 38 | +prod: |
| 39 | + docker compose up -d |
| 40 | + @echo "" |
| 41 | + @echo "✅ Production environment started!" |
| 42 | + @echo " Backend: http://localhost:8000" |
| 43 | + @echo " Frontend: http://localhost:3000" |
| 44 | + |
| 45 | +# Build images |
| 46 | +build: |
| 47 | + docker compose build |
| 48 | + |
| 49 | +# Stop services |
| 50 | +stop: |
| 51 | + docker compose down |
| 52 | + docker compose -f docker-compose.dev.yml down |
| 53 | + |
| 54 | +# Clean everything (including volumes) |
| 55 | +clean: |
| 56 | + docker compose down -v |
| 57 | + docker compose -f docker-compose.dev.yml down -v |
| 58 | + @echo "✅ Cleaned all containers and volumes" |
| 59 | + |
| 60 | +# View logs |
| 61 | +logs: |
| 62 | + docker compose logs -f |
| 63 | + |
| 64 | +# Run backend tests |
| 65 | +test: |
| 66 | + cd backend && python -m pytest tests/ -v |
| 67 | + |
| 68 | +# Run tests in watch mode |
| 69 | +test-watch: |
| 70 | + cd backend && python -m pytest tests/ -v --looponfail |
| 71 | + |
| 72 | +# Run tests with coverage |
| 73 | +coverage: |
| 74 | + cd backend && python -m pytest tests/ --cov=. --cov-report=html --cov-report=term |
| 75 | + @echo "" |
| 76 | + @echo "Coverage report: backend/htmlcov/index.html" |
| 77 | + |
| 78 | +# Deploy backend to Railway |
| 79 | +deploy-backend: |
| 80 | + @echo "🚀 Deploying backend to Railway..." |
| 81 | + railway up |
| 82 | + @echo "✅ Backend deployed!" |
| 83 | + |
| 84 | +# Deploy frontend to Vercel |
| 85 | +deploy-frontend: |
| 86 | + @echo "🚀 Deploying frontend to Vercel..." |
| 87 | + cd frontend && vercel --prod |
| 88 | + @echo "✅ Frontend deployed!" |
| 89 | + |
| 90 | +# Deploy everything |
| 91 | +deploy-all: deploy-backend deploy-frontend |
| 92 | + @echo "✅ All services deployed!" |
| 93 | + |
| 94 | +# Quick restart of backend (for dev) |
| 95 | +restart-backend: |
| 96 | + docker compose restart backend |
| 97 | + @echo "✅ Backend restarted" |
| 98 | + |
| 99 | +# Quick restart of frontend (for dev) |
| 100 | +restart-frontend: |
| 101 | + docker compose restart frontend |
| 102 | + @echo "✅ Frontend restarted" |
| 103 | + |
| 104 | +# Shell into backend container |
| 105 | +shell-backend: |
| 106 | + docker compose exec backend bash |
| 107 | + |
| 108 | +# Shell into Redis |
| 109 | +shell-redis: |
| 110 | + docker compose exec redis redis-cli |
| 111 | + |
| 112 | +# View Redis stats |
| 113 | +redis-stats: |
| 114 | + docker compose exec redis redis-cli INFO |
| 115 | + |
| 116 | +# Check service health |
| 117 | +health: |
| 118 | + @echo "Checking services..." |
| 119 | + @curl -s http://localhost:8000/health | python -m json.tool || echo "❌ Backend not responding" |
| 120 | + @curl -s http://localhost:3000 > /dev/null && echo "✅ Frontend is up" || echo "❌ Frontend not responding" |
| 121 | + @docker compose exec redis redis-cli ping > /dev/null && echo "✅ Redis is up" || echo "❌ Redis not responding" |
| 122 | + |
| 123 | +# Install dependencies (local dev without Docker) |
| 124 | +install-backend: |
| 125 | + cd backend && pip install -r requirements.txt |
| 126 | + |
| 127 | +install-frontend: |
| 128 | + cd frontend && npm install |
| 129 | + |
| 130 | +# Run locally without Docker |
| 131 | +run-backend-local: |
| 132 | + cd backend && uvicorn main:app --reload --port 8000 |
| 133 | + |
| 134 | +run-frontend-local: |
| 135 | + cd frontend && npm run dev |
0 commit comments