build: 自动化上传最小服务器文件的脚本
This commit is contained in:
parent
c300ba400d
commit
2eaf15efa8
|
|
@ -7,6 +7,8 @@ import "./src/env.js";
|
|||
/** @type {import("next").NextConfig} */
|
||||
const config = {
|
||||
devIndicators: false,
|
||||
output: "standalone",
|
||||
productionBrowserSourceMaps: false,
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
#!/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 <remote> <remote_app_dir> [--restart]
|
||||
|
||||
Arguments:
|
||||
remote SSH target, e.g. user@example.com
|
||||
remote_app_dir Remote deerflow2 root dir, e.g. /home/user/deerflow2
|
||||
|
||||
Options:
|
||||
--restart Run "make start" on the remote host after upload
|
||||
|
||||
Example:
|
||||
./scripts/deploy-frontend-standalone.sh ubuntu@1.2.3.4 /opt/deerflow2 --restart
|
||||
|
||||
Notes:
|
||||
- Run this script on your local machine (build machine), not on the server.
|
||||
- Requires: pnpm, rsync, ssh
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REMOTE="$1"
|
||||
REMOTE_APP_DIR="$2"
|
||||
RESTART="${3:-}"
|
||||
|
||||
if [ "$RESTART" != "" ] && [ "$RESTART" != "--restart" ]; then
|
||||
echo "Unknown option: $RESTART"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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 --delete --info=progress2 \
|
||||
frontend/.next/static/ \
|
||||
"$REMOTE:$REMOTE_APP_DIR/frontend/.next/static/"
|
||||
|
||||
echo "==> Uploading public assets..."
|
||||
rsync -azP --delete --info=progress2 \
|
||||
frontend/public/ \
|
||||
"$REMOTE:$REMOTE_APP_DIR/frontend/public/"
|
||||
|
||||
if [ "$RESTART" = "--restart" ]; then
|
||||
echo "==> Restarting DeerFlow on remote host..."
|
||||
ssh "$REMOTE" "cd '$REMOTE_APP_DIR' && make start"
|
||||
fi
|
||||
|
||||
echo "==> Done."
|
||||
|
|
@ -30,8 +30,13 @@ done
|
|||
if $DEV_MODE; then
|
||||
FRONTEND_CMD="pnpm run dev"
|
||||
else
|
||||
# Use existing build artifacts, don't rebuild
|
||||
FRONTEND_CMD="env BETTER_AUTH_SECRET=$(python3 -c 'import secrets; print(secrets.token_hex(16))') pnpm run start"
|
||||
# Use existing build artifacts, don't rebuild.
|
||||
# Prefer Next standalone output to reduce deployment artifact size.
|
||||
if [ -f "$REPO_ROOT/frontend/.next/standalone/server.js" ]; then
|
||||
FRONTEND_CMD="env BETTER_AUTH_SECRET=$(python3 -c 'import secrets; print(secrets.token_hex(16))') node .next/standalone/server.js"
|
||||
else
|
||||
FRONTEND_CMD="env BETTER_AUTH_SECRET=$(python3 -c 'import secrets; print(secrets.token_hex(16))') pnpm run start"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── Stop existing services ────────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Reference in New Issue