Files
hometown/run.sh
2026-03-07 23:47:29 +08:00

21 lines
810 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
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
# 部署流程:拉代码 → 安装依赖 → 构建前端到 dist/ → 启动后端 API5599
# 若 Nginx 未反代 /api请先设置 API_BASE_URL 再执行,例如:
# export API_BASE_URL="http://你的域名或IP:5599"
# ./run.sh
# 若 Nginx 已将 /api 反代到本机 5599可留空 api.config.jsonapiBase 为空即可)。
set -e
cd "$(dirname "$0")"
git fetch origin && git reset --hard origin/master
npm install --no-audit --no-fund
# 若设置了 API_BASE_URL则写入 api.config.json供 build 复制到 dist/
if [ -n "$API_BASE_URL" ]; then
echo "[run.sh] 使用 API_BASE_URL=$API_BASE_URL"
node -e "require('fs').writeFileSync('api.config.json', JSON.stringify({ apiBase: process.env.API_BASE_URL }, null, 2))"
fi
node build.js
bash start-api.sh