From bbef8eeac38b902b49153039ec785c97053f2384 Mon Sep 17 00:00:00 2001 From: kempersc Date: Fri, 16 Jan 2026 14:17:46 +0100 Subject: [PATCH] feat: add --frontend-server flag for server-side builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds frontend on server (91.98.224.44) instead of locally. Recommended for low-RAM machines where Vite builds hang. - Added DEPLOY_FRONTEND_SERVER variable - Added --frontend-server CLI flag - Updated --all to use server build by default - Server build: git pull → pnpm install → pnpm build → rsync to /var/www/ --- infrastructure/deploy.sh | 56 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/infrastructure/deploy.sh b/infrastructure/deploy.sh index ec232f80d0..e65ff5ac38 100755 --- a/infrastructure/deploy.sh +++ b/infrastructure/deploy.sh @@ -6,7 +6,8 @@ # Options: # --infra Deploy infrastructure changes (Terraform) # --data Deploy ontologies directly to Oxigraph (no intermediate storage) -# --frontend Build and deploy frontend (bronhouder.nl) +# --frontend Build locally and deploy frontend (bronhouder.nl) - SLOW on low-RAM machines +# --frontend-server Build on server and deploy frontend (RECOMMENDED) # --archief Build and deploy archief-assistent (archief.support) # --api Deploy FastAPI backend (DSPy SPARQL generation) # --ducklake Deploy DuckLake API backend @@ -68,12 +69,13 @@ DEPLOY_DUCKLAKE=false DEPLOY_QDRANT=false DEPLOY_VALKEY=false DEPLOY_RAG=false +DEPLOY_FRONTEND_SERVER=false CLEAR_OXIGRAPH=false STATUS_ONLY=false SYNC_REVIEWS=false if [ $# -eq 0 ]; then - echo "Usage: $0 [--infra] [--data] [--frontend] [--archief] [--api] [--ducklake] [--qdrant] [--valkey] [--rag] [--all] [--status] [--clear] [--sync-reviews]" + echo "Usage: $0 [--infra] [--data] [--frontend] [--frontend-server] [--archief] [--api] [--ducklake] [--qdrant] [--valkey] [--rag] [--all] [--status] [--clear] [--sync-reviews]" exit 1 fi @@ -88,6 +90,9 @@ for arg in "$@"; do --frontend) DEPLOY_FRONTEND=true ;; + --frontend-server) + DEPLOY_FRONTEND_SERVER=true + ;; --archief) DEPLOY_ARCHIEF=true ;; @@ -112,7 +117,7 @@ for arg in "$@"; do --all) DEPLOY_INFRA=true DEPLOY_DATA=true - DEPLOY_FRONTEND=true + DEPLOY_FRONTEND_SERVER=true # Use server build (faster, recommended) DEPLOY_ARCHIEF=true DEPLOY_API=true DEPLOY_DUCKLAKE=true @@ -277,7 +282,7 @@ if [ -z "$SERVER_IP" ]; then fi # Wait for SSH (needed for all deployment operations) -if [ "$DEPLOY_DATA" = true ] || [ "$DEPLOY_FRONTEND" = true ] || [ "$DEPLOY_ARCHIEF" = true ] || [ "$DEPLOY_API" = true ] || [ "$DEPLOY_DUCKLAKE" = true ] || [ "$DEPLOY_QDRANT" = true ] || [ "$DEPLOY_RAG" = true ]; then +if [ "$DEPLOY_DATA" = true ] || [ "$DEPLOY_FRONTEND" = true ] || [ "$DEPLOY_FRONTEND_SERVER" = true ] || [ "$DEPLOY_ARCHIEF" = true ] || [ "$DEPLOY_API" = true ] || [ "$DEPLOY_DUCKLAKE" = true ] || [ "$DEPLOY_QDRANT" = true ] || [ "$DEPLOY_RAG" = true ]; then wait_for_ssh "$SERVER_IP" fi @@ -552,6 +557,49 @@ if [ "$DEPLOY_FRONTEND" = true ]; then echo -e "${GREEN}Frontend deployment complete${NC}" fi +# Deploy frontend (server-side build - recommended for low-RAM machines) +if [ "$DEPLOY_FRONTEND_SERVER" = true ]; then + echo "" + echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" + echo -e "${BLUE} Building Frontend on Server (Recommended)${NC}" + echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" + + # Push local changes first + echo -e "${YELLOW}Pushing local changes to git...${NC}" + cd "$PROJECT_ROOT" + git push origin master 2>&1 || echo " (Nothing to push or push failed - continuing anyway)" + + # Build on server + echo -e "${YELLOW}Building on server (pulling, installing, building, deploying)...${NC}" + ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" << 'ENDSSH' + set -e + cd /opt/glam + + # Pull latest changes + echo "Pulling latest changes..." + git pull origin master + + # Install dependencies if needed + echo "Installing dependencies..." + pnpm install --frozen-lockfile 2>/dev/null || pnpm install + + # Build frontend + echo "Building frontend..." + cd frontend + pnpm build + + # Deploy to production + echo "Deploying to /var/www/glam-frontend/..." + rsync -av --delete dist/ /var/www/glam-frontend/ + + echo "Build and deployment complete!" +ENDSSH + + cd "$PROJECT_ROOT" + + echo -e "${GREEN}Server-side frontend deployment complete${NC}" +fi + # Deploy archief-assistent (archief.support) if [ "$DEPLOY_ARCHIEF" = true ]; then echo ""