- Updated Dockerfile configurations for various environments (alpine, basic, cloudrun, minimal, simple, test) to ensure compatibility with Laravel 5.0 and PHP 5.6. - Added PHP compatibility documentation outlining mcrypt requirements and upgrade paths. - Created cloudbuild.yaml for Google Cloud Build integration to streamline deployment to Cloud Run. - Introduced docker-compose.local.yml for local development with MySQL and Redis services. - Enhanced rebuild.sh script for easier local development and migration handling. - Updated Laravel Blade views to correct asset paths. - Added start-local.sh script for quick local setup and service management.
106 lines
3.0 KiB
Bash
Executable File
106 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Check if docker compose (new) or docker-compose (old) is available
|
|
if command -v docker &>/dev/null; then
|
|
if docker compose version &>/dev/null; then
|
|
DOCKER_COMPOSE="docker compose"
|
|
elif command -v docker-compose &>/dev/null; then
|
|
DOCKER_COMPOSE="docker-compose"
|
|
else
|
|
echo "❌ Error: Neither 'docker compose' nor 'docker-compose' found."
|
|
echo "Please install Docker Desktop from https://www.docker.com/products/docker-desktop/"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "❌ Error: Docker is not installed."
|
|
echo "Please install Docker Desktop from https://www.docker.com/products/docker-desktop/"
|
|
exit 1
|
|
fi
|
|
|
|
echo "🚀 Starting rebuild process..."
|
|
|
|
# Function to display usage
|
|
show_usage() {
|
|
echo "Usage: ./rebuild.sh [OPTIONS]"
|
|
echo "Options:"
|
|
echo " -h, --help Show this help message"
|
|
echo " -c, --clean Perform a clean rebuild (no cache)"
|
|
echo " -f, --fresh Perform a fresh migration"
|
|
}
|
|
|
|
# Default values
|
|
CLEAN_BUILD=false
|
|
FRESH_MIGRATION=false
|
|
|
|
# Parse arguments
|
|
while [[ "$#" -gt 0 ]]; do
|
|
case $1 in
|
|
-h|--help) show_usage; exit 0 ;;
|
|
-c|--clean) CLEAN_BUILD=true ;;
|
|
-f|--fresh) FRESH_MIGRATION=true ;;
|
|
*) echo "Unknown parameter: $1"; show_usage; exit 1 ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# Pull latest changes from git
|
|
echo "📥 Pulling latest changes from git..."
|
|
if ! git pull; then
|
|
echo "❌ Git pull failed. Please resolve any conflicts and try again."
|
|
exit 1
|
|
fi
|
|
|
|
# Stop running containers
|
|
echo "📥 Stopping running containers..."
|
|
$DOCKER_COMPOSE down
|
|
|
|
# Remove old images if clean build
|
|
if [ "$CLEAN_BUILD" = true ] ; then
|
|
echo "🧹 Cleaning Docker cache..."
|
|
$DOCKER_COMPOSE rm -f
|
|
docker system prune -f
|
|
fi
|
|
|
|
# Build and start containers
|
|
echo "🏗️ Building containers..."
|
|
if [ "$CLEAN_BUILD" = true ] ; then
|
|
$DOCKER_COMPOSE build --no-cache
|
|
else
|
|
$DOCKER_COMPOSE build
|
|
fi
|
|
|
|
# Start containers
|
|
echo "🚀 Starting containers..."
|
|
$DOCKER_COMPOSE up -d
|
|
|
|
# Wait for the containers to be ready
|
|
echo "⏳ Waiting for containers to be ready..."
|
|
sleep 10
|
|
|
|
# Clear Laravel cache
|
|
echo "🧹 Clearing Laravel cache..."
|
|
$DOCKER_COMPOSE exec app php artisan cache:clear
|
|
$DOCKER_COMPOSE exec app php artisan config:clear
|
|
$DOCKER_COMPOSE exec app php artisan view:clear
|
|
|
|
# Run composer install
|
|
echo "📦 Installing dependencies..."
|
|
$DOCKER_COMPOSE exec app composer install
|
|
|
|
# Generate application key if .env exists and APP_KEY is empty
|
|
if [ -f .env ] && ! grep -q "^APP_KEY=[A-Za-z0-9+/]\{40\}$" .env; then
|
|
echo "🔑 Generating application key..."
|
|
$DOCKER_COMPOSE exec app php artisan key:generate
|
|
fi
|
|
|
|
# Run migrations if requested
|
|
if [ "$FRESH_MIGRATION" = true ] ; then
|
|
echo "🔄 Running fresh migrations..."
|
|
$DOCKER_COMPOSE exec app php artisan migrate:fresh
|
|
else
|
|
echo "🔄 Running migrations..."
|
|
$DOCKER_COMPOSE exec app php artisan migrate
|
|
fi
|
|
|
|
echo "✨ Rebuild completed!"
|
|
echo "🌐 Your application should be available at http://localhost:8080" |