#!/bin/bash # CMC Sales Development Environment Setup Script # Simple, straightforward startup without docker compose watch mode set -e # Parse command line arguments BUILD_CACHE=true for arg in "$@"; do if [[ "$arg" == "--no-cache" ]]; then BUILD_CACHE=false fi done # Check prerequisites if ! command -v docker >/dev/null 2>&1; then echo "Error: Docker is not installed" exit 1 fi if ! command -v docker-compose >/dev/null 2>&1; then echo "Error: Docker Compose is not installed" exit 1 fi echo "Starting CMC Sales Development Environment..." echo "" # Build and start services BUILD_FLAG="" if [[ "$BUILD_CACHE" == "false" ]]; then BUILD_FLAG="--no-cache" echo "Building with --no-cache (this may take a while)..." else echo "Building services..." fi if [[ "$BUILD_CACHE" == "false" ]]; then docker compose build $BUILD_FLAG docker compose up -d else docker compose up --build -d fi echo "" echo "Waiting for services to be ready..." sleep 5 # Check database if docker compose exec -T db mariadb-admin ping -h localhost -u cmc -p'xVRQI&cA?7AU=hqJ!%au' --silent 2>/dev/null; then echo "Database is ready" else echo "Warning: Database may still be starting..." fi echo "" echo "Development environment is running." echo "" echo "Available services:" echo " CakePHP (Legacy): http://cmclocal (add to /etc/hosts: 127.0.0.1 cmclocal)" echo " Go (Modern): http://localhost:8080" echo " Database: localhost:3306 (user: cmc)" echo "" echo "Useful commands:" echo " View logs: docker compose logs -f" echo " Stop services: docker compose down" echo " Restart Go app: docker compose restart cmc-go" echo " Restart PHP app: docker compose restart cmc-php" echo ""