Files
YelayMaths/deploy/deploy.config.example.sh
2026-09-30 11:02:58 +08:00

53 lines
2.7 KiB
Bash
Raw Permalink 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.
# 复制本文件为 deploy.config.sh 并填写自己的服务器信息。
# deploy.config.sh 已 gitignore,服务器地址不会进仓库。
# ---- SSH ----
DEPLOY_HOST='1.2.3.4' # 服务器 IP 或域名
DEPLOY_PORT=22
DEPLOY_USER='root'
# 服务器上 Node 的 bin 目录(远端构建时会加进 PATH)。
# 宝塔 → 软件商店 → Node 版本管理器里看,例如 /www/server/nodejs/v22.14.0/bin
NODE_BIN='/www/server/nodejs/v22/bin'
# ---- Nginx 反代缓存 ----
# 宝塔在 /www/server/nginx/conf/proxy.conf 里全局开了 proxy_cache cache_one,
# 而 Next.js 给页面的响应头是 Cache-Control: s-maxage=31536000(允许缓存一年)。
# 两者一叠加,新构建传上去也访问不到,而旧 HTML 引用的分包早被删掉,页面会整块消失。
# 部署脚本每次清一次这个目录并 reload。留空则跳过。
NGINX_CACHE_DIR='/www/server/nginx/proxy_cache_dir'
NGINX_BIN='/www/server/nginx/sbin/nginx'
# ---- yelaymaths_api ----
API_LABEL='yelaymaths_api (server API)'
API_LOCAL='yelaymaths_api'
API_REMOTE='/www/wwwroot/yelaymaths/yelaymaths_api'
API_PATHS='src prisma tools package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json tsconfig.build.json nest-cli.json .env.example'
API_EXCLUDES=''
# 部署前先在服务器上删掉的旧目录(留空表示不删)
API_CLEAN=''
API_LOCAL_BUILD='' # 想在本机构建就填 'pnpm build',一般留空
API_INSTALL='pnpm install --frozen-lockfile'
API_BUILD='pnpm build'
# 重启命令:杀掉旧进程。服务器上执行 pm2 list 看真实进程名。
API_RESTART='pm2 restart yelaymaths-api'
# 拉起命令:宝塔不会自动把进程拉回来,所以自己 setsid + nohup 起。留空则只杀不拉。
API_START='setsid nohup node dist/main.js >> /www/wwwlogs/yelaymaths-api.out.log 2>&1 < /dev/null &'
API_HEALTH='http://127.0.0.1:3002/healthz'
# ---- yelaymaths_admin ----
# 注意:NEXT_PUBLIC_* 是构建时写死的,.env.local 必须在服务器上先准备好(脚本不会上传它)。
ADMIN_LABEL='yelaymaths_admin (admin console)'
ADMIN_LOCAL='yelaymaths_admin'
ADMIN_REMOTE='/www/wwwroot/yelaymaths/yelaymaths_admin'
ADMIN_PATHS='src package.json pnpm-lock.yaml tsconfig.json next.config.ts postcss.config.mjs'
ADMIN_EXCLUDES=''
# Next 的预渲染缓存在 .next/cache 里,命中就不读磁盘新文件,所以每次先删掉重建
ADMIN_CLEAN='.next/cache'
ADMIN_LOCAL_BUILD=''
ADMIN_INSTALL='pnpm install --frozen-lockfile'
ADMIN_BUILD='pnpm build'
ADMIN_RESTART='pm2 restart yelaymaths-admin'
ADMIN_START='setsid nohup node node_modules/next/dist/bin/next start -p 3001 >> /www/wwwlogs/yelaymaths-admin.out.log 2>&1 < /dev/null &'
ADMIN_HEALTH='http://127.0.0.1:3001/'