61 lines
2.3 KiB
Bash
Executable File
61 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# CKB Production Deployment Script
|
|
echo "🚀 Starting CKB Production Deployment..."
|
|
|
|
# Stop existing containers
|
|
echo "📦 Stopping existing containers..."
|
|
docker-compose -f docker-compose.prod.yml down
|
|
|
|
# Remove old images to force rebuild
|
|
echo "🗑️ Removing old images..."
|
|
docker image prune -f
|
|
docker rmi ckb-app-prod 2>/dev/null || true
|
|
|
|
# Build and start containers
|
|
echo "🔨 Building and starting containers..."
|
|
docker-compose -f docker-compose.prod.yml up -d --build
|
|
|
|
# Wait for containers to be ready
|
|
echo "⏳ Waiting for containers to be ready..."
|
|
sleep 30
|
|
|
|
# Clear Laravel caches first
|
|
echo "🧹 Clearing Laravel caches..."
|
|
docker-compose -f docker-compose.prod.yml exec -T app php artisan config:clear
|
|
docker-compose -f docker-compose.prod.yml exec -T app php artisan route:clear
|
|
docker-compose -f docker-compose.prod.yml exec -T app php artisan view:clear
|
|
docker-compose -f docker-compose.prod.yml exec -T app php artisan cache:clear
|
|
|
|
# Run Laravel optimizations
|
|
echo "⚡ Running Laravel optimizations..."
|
|
docker-compose -f docker-compose.prod.yml exec -T app php artisan config:cache
|
|
docker-compose -f docker-compose.prod.yml exec -T app php artisan route:cache
|
|
docker-compose -f docker-compose.prod.yml exec -T app php artisan view:cache
|
|
|
|
# Run migrations (if needed)
|
|
echo "🗄️ Running database migrations..."
|
|
docker-compose -f docker-compose.prod.yml exec -T app php artisan migrate --force
|
|
|
|
# Set proper permissions
|
|
echo "🔐 Setting proper permissions..."
|
|
docker-compose -f docker-compose.prod.yml exec -T app chown -R www-data:www-data /var/www/html/storage
|
|
docker-compose -f docker-compose.prod.yml exec -T app chown -R www-data:www-data /var/www/html/bootstrap/cache
|
|
|
|
# Show container status
|
|
echo "📊 Container status:"
|
|
docker-compose -f docker-compose.prod.yml ps
|
|
|
|
# Show logs for debugging
|
|
echo "📝 Recent logs:"
|
|
docker-compose -f docker-compose.prod.yml logs --tail=20
|
|
|
|
echo "✅ Deployment completed!"
|
|
echo "🌐 Application should be available at: http://localhost:8082"
|
|
echo ""
|
|
echo "🔍 Testing asset URLs:"
|
|
echo "CSS: http://localhost:8082/assets/css/app.bundle.min.css"
|
|
echo "JS: http://localhost:8082/assets/js/app.bundle.min.js"
|
|
echo ""
|
|
echo "To check logs: docker-compose -f docker-compose.prod.yml logs -f"
|
|
echo "To check app logs: docker-compose -f docker-compose.prod.yml logs -f app" |