From 661c401b92933403fde1b8f3fc6b1b1e287ed759 Mon Sep 17 00:00:00 2001 From: MT-Mint <798521692@qq.com> Date: Wed, 8 Apr 2026 13:12:34 +0800 Subject: [PATCH] chore(scripts): add frontend standalone deploy script --- scripts/deploy-frontend-standalone.sh | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 scripts/deploy-frontend-standalone.sh diff --git a/scripts/deploy-frontend-standalone.sh b/scripts/deploy-frontend-standalone.sh new file mode 100644 index 00000000..4fd80e7b --- /dev/null +++ b/scripts/deploy-frontend-standalone.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$REPO_ROOT" + +usage() { + cat <<'EOF' +Usage: + ./scripts/deploy-frontend-standalone.sh + +Arguments: + remote SSH target, e.g. user@example.com + remote_app_dir Remote deerflow2 root dir, e.g. /home/user/deerflow2 + +Example: + ./scripts/deploy-frontend-standalone.sh ubuntu@1.2.3.4 /opt/deerflow2 + +Notes: + - Run this script on your local machine (build machine), not on the server. + - Requires: pnpm, rsync, ssh + - Script will run: + sudo systemctl daemon-reload + sudo systemctl restart deerflow.service +EOF +} + +if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then + usage + exit 0 +fi + +if [ "$#" -ne 2 ]; then + usage + exit 1 +fi + +REMOTE="$1" +REMOTE_APP_DIR="$2" + +echo "==> Building frontend (standalone)..." +pnpm -C frontend build + +echo "==> Uploading standalone server..." +rsync -azP --delete --info=progress2 \ + frontend/.next/standalone/ \ + "$REMOTE:$REMOTE_APP_DIR/frontend/.next/standalone/" + +echo "==> Uploading static assets..." +rsync -azP --info=progress2 \ + frontend/.next/static/ \ + "$REMOTE:$REMOTE_APP_DIR/frontend/.next/standalone/.next/static/" + +echo "==> Uploading public assets..." +rsync -azP --info=progress2 \ + frontend/public/ \ + "$REMOTE:$REMOTE_APP_DIR/frontend/.next/standalone/public/" + +echo "==> Reloading systemd and restarting deerflow.service on remote host..." +ssh "$REMOTE" "sudo systemctl daemon-reload && sudo systemctl restart deerflow.service" + +echo "==> Done."