www_engage_os/build.sh
2025-08-14 12:29:57 +02:00

62 lines
2.7 KiB
Bash
Executable File
Raw 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.

#!/usr/bin/env bash
# ------------------------------------------------------------
# OURWORLD Web Production build ( www_threefold_2025 )
# ------------------------------------------------------------
set -e
cd "$(dirname "$0")" # always run from the scripts directory
# -----------------------------------------------------------------
# 1⃣ Configuration adjust these values for your deployment
# -----------------------------------------------------------------
# Folder name that will be used as a URLprefix when the site is
# served from a subdirectory (e.g. https://example.com/threefold/ ).
PREFIX="threefold" # <--- change if you need a different path
# Remote server where the built files should be copied (optional)
REMOTE_USER="root"
REMOTE_HOST="threefold.info"
REMOTE_PATH="/root/hero/www/info/$PREFIX/"
# -----------------------------------------------------------------
# 2⃣ Set the Vite base URL (used by the app at runtime)
# -----------------------------------------------------------------
export VITE_APP_BASE_URL="/$PREFIX"
echo "🔧 Setting VITE_APP_BASE_URL to $VITE_APP_BASE_URL"
# -----------------------------------------------------------------
# 3⃣ Install (exact) dependencies ensures reproducible builds
# -----------------------------------------------------------------
echo "📦 Installing frozen dependencies…"
pnpm install --frozen-lockfile
# -----------------------------------------------------------------
# 4⃣ Build the static site
# -----------------------------------------------------------------
echo "🏗️ Running Vite production build…"
pnpm run build # creates ./dist/
# -----------------------------------------------------------------
# 5⃣ (Optional) Sync the build locally useful for quick testing
# -----------------------------------------------------------------
if [ -d "${HOME}/hero/var/www/$PREFIX" ]; then
echo "🔄 Syncing build to local mirror: ${HOME}/hero/var/www/$PREFIX/"
rsync -av --delete dist/ "${HOME}/hero/var/www/$PREFIX/"
else
echo "⚠️ Local mirror folder not found skipping local rsync"
fi
# -----------------------------------------------------------------
# 6⃣ (Optional) Deploy to the remote threefold server
# -----------------------------------------------------------------
read -p "🚚 Deploy to remote server (${REMOTE_USER}@${REMOTE_HOST})? [y/N] " -n1 answer
echo
if [[ "$answer" =~ ^[Yy]$ ]]; then
echo "🔐 Syncing build to remote host…"
rsync -avz --delete dist/ "${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}"
echo "✅ Remote deployment finished."
else
echo "⏭️ Remote deployment skipped."
fi
echo "🏁 Build script completed."