This commit is contained in:
2025-08-14 12:29:57 +02:00
parent 3657932051
commit 06110ee319
52 changed files with 4828 additions and 152 deletions

62
build.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/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."