fix:优化启动配置
This commit is contained in:
21
run.sh
Normal file
21
run.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
# 部署流程:拉代码 → 安装依赖 → 构建前端到 dist/ → 启动后端 API(5599)
|
||||
# 若 Nginx 未反代 /api,请先设置 API_BASE_URL 再执行,例如:
|
||||
# export API_BASE_URL="http://你的域名或IP:5599"
|
||||
# ./run.sh
|
||||
# 若 Nginx 已将 /api 反代到本机 5599,可留空 api.config.json(apiBase 为空即可)。
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user