packServer/backend/config/deploy.config.example.cjs
liufumingren 228723e0c3 设备端扫码上报 + 桌面端/Android 正式包发布脚手架
AndroidStation(原中控改造为纯设备端)
- 只做三件事:UDP 48899 被桌面端发现、TCP 8087 推送 USB 扫码结果、离线语音播报
- 扫码不再经过 UI:去掉逐键重绘,50ms 自动提交,同一码重复扫码也一律上报
- 离线语音种子(数字/字母/“开始打包”/欢迎语)随包安装,MediaPlayer 播放,启动把音量拉满
- 启动播报「欢迎使用溯源系统,初始化已经完成,扫码即可开始打包」
- 移除 Device Owner / 设备管理员 / lock task / 网络与 IP 设置等非普通应用能力(仅保留开机自启)
- 正式签名 keystore + release 签名配置,versionName/versionCode 可由打包脚本覆盖

发布脚手架
- backend/android_client:Android 正式包构建(build.ps1 + package.config.json)
- backend/scripts/deploy/publish-android.cjs + npm run android:build / android:publish
- 桌面端安装包改为 download/desktop,Android 为 download/android_client;
  version.json 仍走 /download/version.json(老客户端写死),新增 /download/android_client/version.json
- 谷歌插件随桌面端 MSI 安装到 <安装目录>\extension,工具菜单新增「复制谷歌插件地址」
- git-safety-check 增加仓库级禁区(keystore.properties / *.jks / local.properties)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-21 05:53:27 +08:00

100 lines
4.4 KiB
JavaScript
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.

'use strict';
/**
* 发布配置模板(提交到仓库)
*
* 复制为 config/deploy.config.local.cjs 后填入真实 SSH 信息:
* Copy-Item config/deploy.config.example.cjs config/deploy.config.local.cjs
*
* config/deploy.config.local.cjs 已被 .gitignore 忽略,禁止提交。
*/
module.exports = {
production: {
// ==================== SSH ====================
host: '__FILL_SSH_HOST__',
port: 22,
username: '__FILL_SSH_USERNAME__',
// 绝对路径;Windows 写法示例:C:/Users/you/.ssh/id_rsa
privateKeyPath: 'C:/Users/your-user/.ssh/id_rsa',
// ==================== 远端目录 ====================
// 双实例目录:${deployRoot}/v1、${deployRoot}/v2;
// ${deployRoot}/current.md 记录当前活跃版本,${deployRoot}/.deploy 存放发布包/备份/状态。
deployRoot: '/www/wwwroot/packService',
// v1 / v2 两个实例的监听端口(egg config.cluster.listen.port 由启动脚本的 PORT 覆盖)
ports: { v1: 7301, v2: 7302 },
// ==================== 健康检查 ====================
// /health 会同时检查 MySQL / Redis,任一不可用即 503
healthCheckPath: '/health',
healthCheckAttempts: 30,
healthCheckInterval: 2,
// Nginx upstream 文件(内容只有一行 proxy_pass)。置空字符串则不自动切换。
// 需要在 Nginx 配置里 include 这个文件,例如:
// upstream pack_service { include /www/wwwroot/packService/nginx-upstream.conf; }
nginxUpstreamFile: '/www/wwwroot/packService/nginx-upstream.conf',
// 服务端私有配置目录(不随发布包走):可放 config.prod.js / config.local.js;
// envFile 会在启动前被 source,用于 JWT_SECRET、数据库密码等环境变量。
sharedConfigDir: '/www/wwwroot/packService/shared-config',
envFile: 'env.prod.sh',
// 本机权威 env 副本(已 gitignore);存在时发布前自动上传到 shared-config/
envFileLocalPath: 'config/env.prod.sh',
uploadEnvFile: true,
// ==================== 发布内容 ====================
// 远端保留目录(清理旧代码时跳过)
sharedDirs: [ 'node_modules', 'logs', 'run', 'temp' ],
// 服务端私有文件/目录:发布前暂存、解压后放回,不会被发布包覆盖或删除。
// config/config.prod.js 需要运维在服务器上首次放置(数据库/Redis 密码等)。
preservePaths: [
'config/config.prod.js',
'config/config.local.js',
'app/public/download',
'app/public/version',
],
// 发布前本地构建 ../frontend,产物单独上传到 frontendDeployDir(由 nginx 托管)
buildFrontend: true,
frontendDir: '../frontend',
// 前端构建产物由 nginx 直接托管(上一版保留在 frontend.prev,供回退)
frontendDeployDir: '/www/wwwroot/packService/frontend',
// 由发布脚本维护的 nginx 前端/反代配置(站点配置里 include)
nginxFrontConf: '/www/wwwroot/packService/front.conf',
manageNginxFrontConf: true,
serverName: 'pack.example.com',
// 桌面端发布(npm run desktop:publish):只构建/上传安装包,不动后端
desktopBuildScript: '../desktop/installer/build.ps1',
desktopOutDir: '../desktop/installer/out',
// 安装包目录(nginx 长缓存):deployRoot/download/desktop/YuncangTraceSetup-x.y.z.msi
desktopDownloadDir: '/www/wwwroot/packService/download/desktop',
// version.json 目录(nginx 对 /download/version.json 关缓存,客户端路径不变)
desktopVersionDir: '/www/wwwroot/packService/download',
desktopBaseUrl: 'https://pack.example.com',
desktopKeepVersions: 5,
desktopOwner: 'www:www',
// Android 设备端发布(npm run android:publish):同样只构建/上传 APK
androidBuildScript: 'android_client/build.ps1',
androidOutDir: 'android_client/out',
androidDownloadDir: '/www/wwwroot/packService/download/android_client',
androidVersionDir: '/www/wwwroot/packService/download/android_client',
androidBaseUrl: 'https://pack.example.com',
androidKeepVersions: 5,
androidOwner: 'www:www',
// 目标目录 npm install --production 后是否执行 npm run db:deploy
remoteDbDeploy: false,
// 保留最近多少个备份包(backup-*.tar.gz)
keepBackups: 5,
sshOptions: [
'StrictHostKeyChecking=accept-new',
],
},
};