cmc-sales/start-development.sh

69 lines
1.7 KiB
Bash
Raw Normal View History

2025-07-02 05:04:36 -07:00
#!/bin/bash
# CMC Sales Development Environment Setup Script
# Simple, straightforward startup without docker compose watch mode
2025-07-02 05:04:36 -07:00
set -e
# Parse command line arguments
BUILD_CACHE=true
for arg in "$@"; do
if [[ "$arg" == "--no-cache" ]]; then
BUILD_CACHE=false
fi
done
2025-07-02 05:04:36 -07:00
# Check prerequisites
if ! command -v docker >/dev/null 2>&1; then
echo "Error: Docker is not installed"
2025-07-02 05:04:36 -07:00
exit 1
fi
if ! command -v docker-compose >/dev/null 2>&1; then
echo "Error: Docker Compose is not installed"
2025-07-02 05:04:36 -07:00
exit 1
fi
echo "Starting CMC Sales Development Environment..."
2025-07-02 05:04:36 -07:00
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)..."
2025-07-02 05:04:36 -07:00
else
echo "Building services..."
2025-07-02 05:04:36 -07:00
fi
if [[ "$BUILD_CACHE" == "false" ]]; then
docker compose build $BUILD_FLAG
docker compose up -d
2025-07-02 05:04:36 -07:00
else
docker compose up --build -d
fi
2025-07-02 05:04:36 -07:00
echo ""
echo "Waiting for services to be ready..."
sleep 5
2025-07-02 05:04:36 -07:00
# 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
2025-07-02 05:04:36 -07:00
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 ""