#!/bin/bash set -e # Colors GREEN='\033[0;32m' BLUE='\033[0;34m' NC='\033[0m' echo -e "${BLUE}🚀 Starting Veza Minimal Web Stack...${NC}" # Source env if [ -f .env ]; then export $(grep -v '^#' .env | xargs) fi # 1. Start Infrastructure (Background) echo -e "${BLUE}📦 Starting Database & Redis...${NC}" docker compose -f docker-compose.yml up -d postgres redis # Wait for DB echo -e "${BLUE}⏳ Waiting for DB...${NC}" until docker compose -f docker-compose.yml exec -T postgres pg_isready -U veza > /dev/null 2>&1; do echo -n "."; sleep 1; done echo -e " ${GREEN}OK${NC}" # 2. Check/Run Migrations (Go) echo -e "${BLUE}🔄 Checking Migrations...${NC}" cd veza-backend-api go run cmd/migrate_tool/main.go up cd .. # 3. Start Backend (Background) echo -e "${BLUE}⚙️ Starting Backend API (port 8080)...${NC}" # Use standard run, not hot reload for stability in this script, or use air if available? # Let's use simple go run to be robust. (cd veza-backend-api && go run cmd/api/main.go) > backend.log 2>&1 & BACKEND_PID=$! echo $BACKEND_PID > backend.pid echo -e "${GREEN}✅ Backend running (PID: $BACKEND_PID). Logs: backend.log${NC}" # 4. Start Frontend echo -e "${BLUE}🎨 Starting Frontend (port 5173)...${NC}" echo -e "${GREEN}👉 App will be available at http://localhost:5173${NC}" (cd apps/web && npm run dev) > frontend.log 2>&1 & FRONTEND_PID=$! echo $FRONTEND_PID > frontend.pid echo -e "${GREEN}✅ All services started.${NC}" echo -e "${BLUE}Type 'make stop-minimal' to stop.${NC}" # Wait for user input or keep alive? # We exit, letting processes run in background? # Usually 'make' commands blocking is better for the user to Ctrl+C. # But 'npm run dev' is interactive-ish. # Let's block on the frontend process. wait $FRONTEND_PID