#!/bin/bash set -e echo "======================================" echo "MinIO WebUI Development Environment" echo "======================================" echo "" # Colors for output GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Check if .env exists if [ ! -f .env ]; then echo -e "${YELLOW}Warning: .env file not found. Copying from .env.example${NC}" cp .env.example .env echo -e "${GREEN}✓ Created .env file. Please update it with your configuration.${NC}" fi # Export ports for development export PORT=7510 export FRONTEND_PORT=7511 echo -e "${BLUE}Starting services:${NC}" echo "- Backend API: http://localhost:7510" echo "- Frontend UI: http://localhost:7511" echo "" # Check if running in Docker mode or local mode if [ "$1" == "docker" ]; then echo "Starting with Docker..." docker compose -f docker-compose.dev.yml up else echo "Starting in local development mode..." # Start Redis if not running if ! command -v redis-cli &> /dev/null || ! redis-cli ping &> /dev/null; then echo -e "${YELLOW}Starting Redis...${NC}" redis-server --daemonize yes fi # Install backend dependencies echo -e "${BLUE}Installing backend dependencies...${NC}" cd backend npm install # Start backend echo -e "${BLUE}Starting backend on port 7510...${NC}" PORT=7510 npm run dev & BACKEND_PID=$! cd .. # Install frontend dependencies echo -e "${BLUE}Installing frontend dependencies...${NC}" cd frontend npm install --legacy-peer-deps # Start frontend echo -e "${BLUE}Starting frontend on port 7511...${NC}" PORT=7511 REACT_APP_API_URL=http://localhost:7510/api npm start & FRONTEND_PID=$! cd .. # Function to kill processes on exit cleanup() { echo -e "\n${YELLOW}Stopping services...${NC}" kill $BACKEND_PID $FRONTEND_PID 2>/dev/null || true exit } # Set up trap to clean up on exit trap cleanup EXIT INT TERM echo -e "\n${GREEN}✓ Development environment started!${NC}" echo -e "${BLUE}Press Ctrl+C to stop all services${NC}\n" # Wait for processes wait fi