rackham-meeting-analyzer/update-frontend.sh

84 lines
2.1 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_header() {
echo -e "\n${BLUE}===================================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}===================================================${NC}\n"
}
print_success() {
echo -e "${GREEN}$1${NC}"
}
print_info() {
echo -e "${BLUE} $1${NC}"
}
print_header "Updating Frontend Build"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Load environment variables
if [ -f "$SCRIPT_DIR/infra/.env" ]; then
source "$SCRIPT_DIR/infra/.env"
print_success "Loaded environment from .env"
# Set defaults if not in .env
FRONTEND_BASE_PATH=${FRONTEND_BASE_PATH:-/rackham}
API_BASE_URL=${API_BASE_URL:-https://ai-sandbox.oliver.solutions/rackham-back}
else
print_info "No .env file found, using defaults"
FRONTEND_BASE_PATH="/rackham"
API_BASE_URL="https://ai-sandbox.oliver.solutions/rackham-back"
fi
# Build frontend
print_header "Building Frontend"
cd "$SCRIPT_DIR/frontend"
print_info "Installing dependencies..."
npm ci
print_info "Building with:"
echo " VITE_BASE_PATH=$FRONTEND_BASE_PATH"
echo " VITE_API_BASE=$API_BASE_URL"
echo ""
VITE_BASE_PATH=$FRONTEND_BASE_PATH VITE_API_BASE=$API_BASE_URL npm run build
if [ $? -ne 0 ]; then
echo "Build failed!"
exit 1
fi
print_success "Frontend built successfully"
# Deploy to Apache web root
print_header "Deploying to Apache Web Root"
APACHE_WEB_ROOT="/var/www/html/rackham"
print_info "Deploying to: $APACHE_WEB_ROOT"
sudo mkdir -p "$APACHE_WEB_ROOT"
sudo rm -rf "$APACHE_WEB_ROOT"/*
sudo cp -r dist/* "$APACHE_WEB_ROOT/"
sudo chown -R www-data:www-data "$APACHE_WEB_ROOT"
sudo chmod -R 755 "$APACHE_WEB_ROOT"
FILE_COUNT=$(find "$APACHE_WEB_ROOT" -type f | wc -l)
print_success "Deployed $FILE_COUNT files to $APACHE_WEB_ROOT"
print_header "✅ Frontend Update Complete!"
echo ""
echo "The frontend has been rebuilt and deployed."
echo "Access at: https://ai-sandbox.oliver.solutions/rackham"
echo ""
echo "Hard refresh your browser (Ctrl+Shift+R) to see changes."
echo ""