40 lines
1.2 KiB
Bash
Executable File
40 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# Sync /app/static/ (backend build output) to /var/www/excel.donton.cloud/ (nginx root)
|
|
# Usage: bash /root/aars/deploy_static.sh
|
|
|
|
set -e
|
|
|
|
CONTAINER=$(docker ps -qf name=aars-aars-1)
|
|
if [ -z "$CONTAINER" ]; then
|
|
echo "ERROR: aars-aars-1 container not running"
|
|
exit 1
|
|
fi
|
|
|
|
WEB_ROOT=/var/www/excel.donton.cloud
|
|
echo "Syncing static files from container $CONTAINER -> $WEB_ROOT ..."
|
|
|
|
# Ensure dirs exist
|
|
mkdir -p "$WEB_ROOT/assets"
|
|
|
|
# Copy index.html
|
|
docker cp "$CONTAINER:/app/static/index.html" "$WEB_ROOT/index.html"
|
|
echo " ✓ index.html"
|
|
|
|
# Copy assets
|
|
docker cp "$CONTAINER:/app/static/assets/." "$WEB_ROOT/assets/"
|
|
asset_count=$(ls "$WEB_ROOT/assets/" | wc -l)
|
|
echo " ✓ assets/ ($asset_count files)"
|
|
|
|
# Show what is currently referenced
|
|
current_bundle=$(grep -oE "/assets/index-[A-Za-z0-9_-]+\.js" "$WEB_ROOT/index.html" | head -1)
|
|
echo " → Currently serving: $current_bundle"
|
|
|
|
# Optional: cleanup old bundles (keep only last 5 js + 3 css)
|
|
cd "$WEB_ROOT/assets"
|
|
ls -t index-*.js 2>/dev/null | tail -n +6 | xargs -r rm
|
|
ls -t index-*.css 2>/dev/null | tail -n +4 | xargs -r rm
|
|
remaining=$(ls "$WEB_ROOT/assets/" | wc -l)
|
|
echo " ✓ Cleanup done, $remaining files remaining"
|
|
|
|
echo "Done. Reload https://excel.donton.cloud/"
|