#!/bin/bash # Deployment script for Thanasoft application # This script builds the Vue frontend and deploys to the server set -e # Exit on error echo "==========================================" echo "Thanasoft Deployment Script" echo "==========================================" echo "" # Configuration SERVER_USER="root" SERVER_IP="78.138.58.60" SERVER_PATH="/var/www/html/New-Thanasoft" LOCAL_BACKEND_PATH="./thanasoft-back" LOCAL_FRONTEND_PATH="./thanasoft-front" # Step 1: Build Vue.js frontend echo "📦 Building Vue.js frontend..." cd "$LOCAL_FRONTEND_PATH" npm run build echo "✓ Frontend built successfully" echo "" # Step 2: Check if build was created if [ ! -d "../thanasoft-back/public/build" ]; then echo "❌ Error: Build directory not found!" exit 1 fi echo "✓ Build directory found" echo "" # Step 3: Deploy to server echo "🚀 Deploying to server..." cd .. # Upload backend (routes, controllers, models, etc.) echo "Uploading backend files..." rsync -avz --progress \ --exclude 'node_modules' \ --exclude 'vendor' \ --exclude '.git' \ --exclude 'storage/logs/*' \ --exclude 'storage/framework/cache/*' \ --exclude 'storage/framework/sessions/*' \ --exclude 'storage/framework/views/*' \ "$LOCAL_BACKEND_PATH/" \ "$SERVER_USER@$SERVER_IP:$SERVER_PATH/thanasoft-back/" echo "✓ Backend files uploaded" echo "" # Step 4: Run server commands echo "🔧 Running server commands..." ssh "$SERVER_USER@$SERVER_IP" << 'ENDSSH' cd /var/www/html/New-Thanasoft/thanasoft-back # Set permissions echo "Setting permissions..." chown -R www-data:www-data storage bootstrap/cache public/build chmod -R 775 storage bootstrap/cache # Clear and cache Laravel echo "Clearing Laravel caches..." php artisan route:clear php artisan cache:clear php artisan config:clear php artisan view:clear echo "Caching for production..." php artisan route:cache php artisan config:cache php artisan view:cache # Restart Apache echo "Restarting Apache..." systemctl restart apache2 echo "✓ Server setup complete" ENDSSH echo "" echo "==========================================" echo "✅ Deployment Complete!" echo "==========================================" echo "" echo "Your application is now live at:" echo "🌐 http://78.138.58.60/" echo "🔌 API: http://78.138.58.60/api/" echo ""