#!/bin/bash # Quick start script for local development and testing before Cloud Run deployment set -e echo "🚀 Starting Merchbay Laravel Application Setup..." # Check if Docker is running if ! docker info > /dev/null 2>&1; then echo "❌ Docker is not running. Please start Docker and try again." exit 1 fi # Determine which docker compose command to use if command -v docker-compose > /dev/null 2>&1; then DOCKER_COMPOSE="docker-compose" elif docker compose version > /dev/null 2>&1; then DOCKER_COMPOSE="docker compose" else echo "❌ Neither 'docker-compose' nor 'docker compose' is available." echo "Please install Docker Compose and try again." exit 1 fi echo "â„šī¸ Using: $DOCKER_COMPOSE" # Check if .env file exists if [ ! -f .env ]; then echo "📄 Creating .env file from .env.example..." cp .env.example .env echo "✅ .env file created. Please update it with your configuration." fi # Build and start services echo "🔨 Building Docker images..." $DOCKER_COMPOSE -f docker-compose.local.yml build echo "🚀 Starting services..." $DOCKER_COMPOSE -f docker-compose.local.yml up -d echo "âŗ Waiting for services to be ready..." sleep 30 # Run Laravel setup commands echo "🔧 Setting up Laravel..." $DOCKER_COMPOSE -f docker-compose.local.yml exec app php artisan key:generate #$DOCKER_COMPOSE -f docker-compose.local.yml exec app php artisan migrate --force $DOCKER_COMPOSE -f docker-compose.local.yml exec app php artisan config:cache $DOCKER_COMPOSE -f docker-compose.local.yml exec app php artisan route:cache $DOCKER_COMPOSE -f docker-compose.local.yml exec app php artisan view:cache echo "✅ Setup complete!" echo "" echo "🌐 Your application is now running at:" echo " Application: http://localhost:8080" echo " phpMyAdmin: http://localhost:8081" echo "" echo "📊 Check logs with:" echo " $DOCKER_COMPOSE -f docker-compose.local.yml logs -f app" echo "" echo "🛑 Stop the application with:" echo " $DOCKER_COMPOSE -f docker-compose.local.yml down" echo "" echo "🚀 When ready to deploy to Cloud Run, use:" echo " gcloud builds submit --config=cloudbuild.yaml"