@nocobase/plugin-ai 2.1.0-alpha.46 → 2.1.0-alpha.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/ai/docs/nocobase/ai/install-upgrade-migration.mdx +127 -132
  2. package/dist/ai/docs/nocobase/api/cli/app/autostart/disable.md +44 -0
  3. package/dist/ai/docs/nocobase/api/cli/app/autostart/enable.md +44 -0
  4. package/dist/ai/docs/nocobase/api/cli/app/autostart/index.md +63 -0
  5. package/dist/ai/docs/nocobase/api/cli/app/autostart/list.md +41 -0
  6. package/dist/ai/docs/nocobase/api/cli/app/autostart/run.md +50 -0
  7. package/dist/ai/docs/nocobase/api/cli/app/index.md +18 -15
  8. package/dist/ai/docs/nocobase/api/cli/app/restart.md +3 -11
  9. package/dist/ai/docs/nocobase/api/cli/app/start.md +3 -11
  10. package/dist/ai/docs/nocobase/api/cli/app/stop.md +22 -12
  11. package/dist/ai/docs/nocobase/api/cli/app/upgrade.md +6 -6
  12. package/dist/ai/docs/nocobase/api/cli/backup/create.md +49 -0
  13. package/dist/ai/docs/nocobase/api/cli/backup/index.md +46 -0
  14. package/dist/ai/docs/nocobase/api/cli/backup/restore.md +46 -0
  15. package/dist/ai/docs/nocobase/api/cli/config/delete.md +11 -9
  16. package/dist/ai/docs/nocobase/api/cli/config/get.md +11 -8
  17. package/dist/ai/docs/nocobase/api/cli/config/index.md +28 -24
  18. package/dist/ai/docs/nocobase/api/cli/config/set.md +14 -12
  19. package/dist/ai/docs/nocobase/api/cli/db/stop.md +10 -11
  20. package/dist/ai/docs/nocobase/api/cli/env/index.md +25 -23
  21. package/dist/ai/docs/nocobase/api/cli/env/info.md +12 -10
  22. package/dist/ai/docs/nocobase/api/cli/env/proxy/caddy.md +108 -0
  23. package/dist/ai/docs/nocobase/api/cli/env/proxy/index.md +54 -0
  24. package/dist/ai/docs/nocobase/api/cli/env/proxy/nginx.md +104 -0
  25. package/dist/ai/docs/nocobase/api/cli/env/remove.md +18 -14
  26. package/dist/ai/docs/nocobase/api/cli/env/update.md +115 -14
  27. package/dist/ai/docs/nocobase/api/cli/index.md +66 -52
  28. package/dist/ai/docs/nocobase/api/cli/init.md +244 -62
  29. package/dist/ai/docs/nocobase/api/cli/license/activate.md +13 -12
  30. package/dist/ai/docs/nocobase/api/cli/license/index.md +2 -2
  31. package/dist/ai/docs/nocobase/api/cli/plugin/import.md +74 -0
  32. package/dist/ai/docs/nocobase/api/cli/plugin/index.md +4 -2
  33. package/dist/ai/docs/nocobase/get-started/install-upgrade-plugins.mdx +16 -10
  34. package/dist/ai/docs/nocobase/index.md +3 -3
  35. package/dist/ai/docs/nocobase/quickstart/index.md +27 -0
  36. package/dist/ai/docs/nocobase/quickstart/installation/airgap.md +67 -0
  37. package/dist/ai/docs/nocobase/quickstart/installation/cli.md +205 -0
  38. package/dist/ai/docs/nocobase/quickstart/installation/docker-compose.md +123 -0
  39. package/dist/ai/docs/nocobase/quickstart/installation/env.md +101 -0
  40. package/dist/ai/docs/nocobase/quickstart/installation/migration.md +50 -0
  41. package/dist/ai/docs/nocobase/quickstart/operations/backup-restore.md +94 -0
  42. package/dist/ai/docs/nocobase/quickstart/operations/manage-app.md +166 -0
  43. package/dist/ai/docs/nocobase/quickstart/operations/multi-environment.md +171 -0
  44. package/dist/ai/docs/nocobase/quickstart/plugins/third-party.md +86 -0
  45. package/dist/ai/docs/nocobase/quickstart/production/index.md +163 -0
  46. package/dist/ai/docs/nocobase/quickstart/production/reverse-proxy/caddy.md +158 -0
  47. package/dist/ai/docs/nocobase/quickstart/production/reverse-proxy/index.md +100 -0
  48. package/dist/ai/docs/nocobase/quickstart/production/reverse-proxy/nginx.md +166 -0
  49. package/dist/ai/docs/nocobase/quickstart/release-management.md +1 -0
  50. package/dist/ai/docs/nocobase/workflow/advanced/options.md +45 -1
  51. package/dist/externalVersion.js +16 -16
  52. package/dist/node_modules/@langchain/xai/package.json +1 -1
  53. package/dist/node_modules/fs-extra/package.json +1 -1
  54. package/dist/node_modules/jsonrepair/package.json +1 -1
  55. package/dist/node_modules/just-bash/package.json +1 -1
  56. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  57. package/dist/node_modules/openai/package.json +1 -1
  58. package/dist/node_modules/zod/package.json +1 -1
  59. package/dist/server/workflow/nodes/employee/index.js +2 -4
  60. package/package.json +2 -2
  61. package/dist/ai/docs/nocobase/api/cli/app/down.md +0 -41
@@ -0,0 +1,166 @@
1
+ # 管理应用
2
+
3
+ 如果你已经把一个 NocoBase 应用保存成 CLI env,日常管理基本都在 `nb app` 这一组命令里完成:启动、停止、重启、查看日志、升级,以及清理本地运行资源。
4
+
5
+ 大多数时候,你不需要记住所有参数。先分清楚自己要做的是“把应用跑起来”“看日志排查问题”,还是“彻底清理这个 env”,再选对应命令就行。
6
+
7
+ ## 快速索引
8
+
9
+ | 我想要…… | 用哪个命令 |
10
+ | --- | --- |
11
+ | 启动或恢复应用运行 | [`nb app start`](../../api/cli/app/start.md) |
12
+ | 临时停止应用 | [`nb app stop`](../../api/cli/app/stop.md) |
13
+ | 连同 CLI 托管的内置数据库一起停掉 | [`nb app stop --with-db`](../../api/cli/app/stop.md) |
14
+ | 修改配置后重新拉起应用 | [`nb app restart`](../../api/cli/app/restart.md) |
15
+ | 实时查看应用日志 | [`nb app logs`](../../api/cli/app/logs.md) |
16
+ | 升级到新的源码或镜像版本 | [`nb app upgrade`](../../api/cli/app/upgrade.md) |
17
+ | 移除 env 配置,但保留 storage 和本地 app 文件 | [`nb env remove`](../../api/cli/env/remove.md) |
18
+ | 连同本机托管资源一起彻底清理 | [`nb env remove --purge`](../../api/cli/env/remove.md) |
19
+
20
+ :::tip 先确认当前 env
21
+
22
+ `nb app` 命令默认作用在当前 env 上。如果你同时维护多个环境,默认推荐先切到目标 env,再执行启动、升级或清理操作。
23
+
24
+ ```bash
25
+ nb env current
26
+ nb env use app1
27
+ ```
28
+
29
+ 如果你显式传入了不同的 `--env`,CLI 通常会要求确认。脚本或非交互场景里,可以加 `--yes` 跳过这一步。
30
+
31
+ :::
32
+
33
+ ## 启动应用
34
+
35
+ 把应用拉起来,默认用 `nb app start` 就行:
36
+
37
+ ```bash
38
+ nb app start
39
+ ```
40
+
41
+ 如果你要操作的不是当前 env,可以显式指定:
42
+
43
+ ```bash
44
+ nb app start --env app1 --yes
45
+ ```
46
+
47
+ 另外几个比较常用的启动参数:
48
+
49
+ ```bash
50
+ nb app start --no-daemon
51
+ ```
52
+
53
+ - `nb app start` 默认会先自动完成必要的安装或升级准备,再把服务拉起来
54
+ - `--no-daemon` 只在本地 env 下有明显意义——应用会以前台模式运行,方便你直接看控制台输出
55
+
56
+ 本地 npm/Git env 会启动本地应用进程,Docker env 会按已保存配置重建应用容器。详细参数见 [`nb app start`](../../api/cli/app/start.md)。
57
+
58
+ ## 停止和重启
59
+
60
+ 只想临时把应用停掉,用 `nb app stop`:
61
+
62
+ ```bash
63
+ nb app stop
64
+ ```
65
+
66
+ 如果你刚改完配置、依赖或代码,通常来说直接 `nb app restart` 更省事:
67
+
68
+ ```bash
69
+ nb app restart
70
+ nb app restart --env app1 --yes
71
+ ```
72
+
73
+ `nb app restart` 会先执行停止,再按 `start` 的方式重新启动,所以它也支持 `--no-daemon` 这类启动参数。详细用法见 [`nb app stop`](../../api/cli/app/stop.md) 和 [`nb app restart`](../../api/cli/app/restart.md)。
74
+
75
+ ## 查看日志
76
+
77
+ 排查问题时,通常先看日志:
78
+
79
+ ```bash
80
+ nb app logs
81
+ ```
82
+
83
+ 如果你只想多看一点最近输出,或者不想持续跟随日志,可以这样用:
84
+
85
+ ```bash
86
+ nb app logs --tail 200
87
+ nb app logs --no-follow
88
+ nb app logs --env app1 --yes
89
+ ```
90
+
91
+ 本地 npm/Git env 读取的是 pm2 日志,Docker env 读取的是容器日志。默认情况下,`nb app logs` 会持续跟随新日志输出。详细参数见 [`nb app logs`](../../api/cli/app/logs.md)。
92
+
93
+ ## 升级应用
94
+
95
+ 升级命令是 `nb app upgrade`:
96
+
97
+ ```bash
98
+ nb app upgrade
99
+ ```
100
+
101
+ 这个命令做的不只是“下载新版本”。默认流程通常包括:
102
+
103
+ 1. 停止当前应用
104
+ 2. 下载并替换已保存的源码或镜像
105
+ 3. 同步商业插件
106
+ 4. 升级并启动应用
107
+ 5. 刷新 env runtime 信息
108
+
109
+ 如果你已经提前更新好了源码或镜像,只想基于当前内容继续执行升级并启动应用,可以加 `--skip-download`:
110
+
111
+ ```bash
112
+ nb app upgrade --skip-download
113
+ ```
114
+
115
+ 如果你想显式指定目标版本,也可以加 `--version`:
116
+
117
+ ```bash
118
+ nb app upgrade --version beta
119
+ ```
120
+
121
+ :::warning 注意
122
+
123
+ `nb app upgrade` 在真正开始前通常还会要求你确认一次。脚本、CI 或其他非交互场景里,需要显式传入 `--force`。如果同时还是跨 env 操作,通常要一起带上 `--yes`。
124
+
125
+ ```bash
126
+ nb app upgrade --env app1 --yes --force
127
+ ```
128
+
129
+ :::
130
+
131
+ 更完整的参数说明见 [`nb app upgrade`](../../api/cli/app/upgrade.md)。
132
+
133
+ ## 清理运行资源和销毁 env
134
+
135
+ 这几种场景最容易混淆。可以先记住一个默认建议:
136
+
137
+ - 只是想把应用停掉,用 `nb app stop`
138
+ - 也想把当前机器上的内置数据库运行时一起停掉,用 `nb app stop --with-db`
139
+ - 确定这个 env 不再需要了,但想先保留 storage 和本地 app 文件,用 `nb env remove`
140
+ - 连本机托管资源也一起清理掉,再用 `nb env remove --purge`
141
+
142
+ 如果你只是想停掉应用和 CLI 托管的内置数据库,直接这样写就行:
143
+
144
+ ```bash
145
+ nb app stop --env app1 --with-db
146
+ ```
147
+
148
+ 如果你要移除这个 env,但还想保留 storage 和本地 app 文件:
149
+
150
+ ```bash
151
+ nb env remove app1 --force
152
+ ```
153
+
154
+ 如果你确实要把这个 env 的本机托管内容也一起清理掉,那么加上 `--purge`:
155
+
156
+ ```bash
157
+ nb env remove app1 --purge --force
158
+ ```
159
+
160
+ 对于 CLI 下载管理的本地 npm/Git env,`--purge` 还会删除 CLI 托管的本地应用文件。对于 HTTP 或 SSH env,它只会删除 CLI 里保存的 env 配置,不会去删除外部服务本身。
161
+
162
+ ## 相关链接
163
+
164
+ - [多环境管理](./multi-environment.md)
165
+ - [`nb app` 命令参考](../../api/cli/app/index.md)
166
+ - [`nb env` 命令参考](../../api/cli/env/index.md)
@@ -0,0 +1,171 @@
1
+ # 多环境管理
2
+
3
+ 如果你同时维护 `dev`、`test`、`staging`、`prod` 等多个 NocoBase 应用,可以把它们分别保存成 CLI env。之后大多数 `nb` 命令都会默认作用在当前 env 上,所以在执行 `nb app`、`nb api`、`nb db` 这类命令前,先确认自己正在用哪个 env 很重要。
4
+
5
+ CLI 从这一版开始把概念拆成了 `current env` 和 `last env`。你通常只需要关心 `current env`——也就是当前 shell 或 agent runtime 正在使用的环境。只有在没有开启 session mode 时,CLI 才会回退到全局 `last env`。
6
+
7
+ ## 快速索引
8
+
9
+ | 我想要…… | 用哪个命令 |
10
+ | --- | --- |
11
+ | 新建一个本地 env,并顺手完成初始化 | [`nb init`](../../api/cli/init.md) |
12
+ | 把一个已有应用登记成 CLI env | [`nb env add`](../../api/cli/env/add.md) |
13
+ | 看本地保存了哪些 env | [`nb env list`](../../api/cli/env/list.md) |
14
+ | 检查所有 env 的连通性和认证状态 | [`nb env status --all`](../../api/cli/env/status.md) |
15
+ | 切换后续命令要使用的 env | [`nb env use`](../../api/cli/env/use.md) |
16
+ | 确认当前命令会落到哪个 env | [`nb env current`](../../api/cli/env/current.md) 和 [`nb env status`](../../api/cli/env/status.md) |
17
+ | 查看某个 env 保存了哪些详细配置 | [`nb env info`](../../api/cli/env/info.md) |
18
+ | 更新已保存的 env 配置,必要时让 CLI 重新同步当前状态 | [`nb env update`](../../api/cli/env/update.md) |
19
+ | 登录态过期后重新认证,或者改用新的认证方式 | [`nb env auth`](../../api/cli/env/auth.md) |
20
+ | 删除不用的 env 配置,必要时连本机托管资源一起清理 | [`nb env remove`](../../api/cli/env/remove.md) |
21
+
22
+ :::tip 建议先开启 session mode
23
+
24
+ 默认推荐先执行一次 [`nb session setup`](../../api/cli/session/setup.md)。这样不同终端、不同 shell,或者不同 agent runtime 可以各自维护自己的 `current env`,并行操作时不容易互相影响。
25
+
26
+ 如果没有开启 session mode,那么 `nb env use` 会回退到更新全局 `last env`。这种情况下,一个终端切走环境,另一个终端也可能跟着受影响。
27
+
28
+ ```bash
29
+ nb session setup
30
+ ```
31
+
32
+ :::
33
+
34
+ ## 创建多个环境
35
+
36
+ 如果你要新建或恢复一个本地应用,用 `nb init` 就行。它会完成初始化,并把结果保存成一个新的 CLI env。
37
+
38
+ ```bash
39
+ nb init --env dev
40
+ nb init --env test
41
+ ```
42
+
43
+ 如果应用已经存在,只是想把它接入 CLI,通常来说用 `nb env add` 更直接:
44
+
45
+ ```bash
46
+ nb env add staging --api-base-url http://staging.example.com/api --auth-type oauth
47
+ nb env add prod --api-base-url https://api.example.com/api --auth-type token --access-token <token>
48
+ ```
49
+
50
+ 前者偏“初始化一个环境”,后者偏“登记一个已有环境”。如果你只是连接已有应用,默认用 `nb env add` 就行。
51
+
52
+ ## 查看已经配置的环境
53
+
54
+ 先用 `nb env list` 看看本地已经保存了哪些 env:
55
+
56
+ ```bash
57
+ nb env list
58
+ ```
59
+
60
+ 这个命令只展示配置本身,不主动检查应用状态。想同时看连通性和认证状态时,用 `nb env status --all`:
61
+
62
+ ```bash
63
+ nb env status --all
64
+ ```
65
+
66
+ 你通常会看到 `ok`、`auth failed`、`unreachable` 这类状态值。
67
+
68
+ ## 切换当前环境
69
+
70
+ 切换环境用 `nb env use`:
71
+
72
+ ```bash
73
+ nb env use dev
74
+ ```
75
+
76
+ 切换完成后,后续省略 `--env` 的命令都会默认使用这个 env。
77
+
78
+ ## 查看当前环境
79
+
80
+ 如果你不确定当前命令会落到哪个环境上,先执行这两个命令:
81
+
82
+ ```bash
83
+ nb env current
84
+ nb env status
85
+ ```
86
+
87
+ `nb env current` 用来看名称,`nb env status` 用来看当前 env 是否可访问、认证是否正常。
88
+
89
+ ## 查看单个 env 的详细信息
90
+
91
+ 想看某个 env 保存了哪些配置,用 `nb env info`:
92
+
93
+ ```bash
94
+ nb env info dev
95
+ nb env info dev --json
96
+ nb env info dev --field app.url
97
+ nb env info dev --show-secrets
98
+ ```
99
+
100
+ 其中,`--field` 适合在脚本里只取一个值。`--show-secrets` 会明文显示 token、密码这类敏感信息,只有在你明确需要排查时再用。
101
+
102
+ ## 更新 env 配置
103
+
104
+ `nb env update` 用来调整一个已保存 env 的配置。比如 API 地址、认证方式、源码来源、应用端口和数据库参数。更新完成后,CLI 会根据变更自动处理后续事宜。
105
+
106
+ 如果你只是想让 CLI 按当前 env 的最新状态重新同步,直接这样写就行:
107
+
108
+ ```bash
109
+ nb env update
110
+ nb env update prod
111
+ ```
112
+
113
+ 如果你要修改这个 env 保存的连接信息或本地配置,可以显式带上参数:
114
+
115
+ ```bash
116
+ nb env update prod --api-base-url https://api.example.com/api
117
+ nb env update prod --access-token <token>
118
+ nb env update dev --app-port 13080 --timezone Asia/Shanghai
119
+ ```
120
+
121
+ 这里可以先记住一个默认判断:
122
+
123
+ - 要修改 env 保存的连接信息或本地配置,用 `nb env update`
124
+ - 应用接口、插件或 CLI 可用能力刚发生变化,也可以再执行一次 `nb env update`
125
+ - 登录态过期了,或者要重新走一遍认证流程,用 `nb env auth`
126
+ - 只是想看当前保存了什么,用 `nb env info`
127
+
128
+ 如果你改的是 `app-port`、`timezone`、`db-*` 这类本地运行配置,`update` 只会改保存值,不会自动重启应用。通常来说后续还要再执行 `nb app restart --env <name>`;如果变更涉及 CLI 托管的内置数据库,则用 `nb app restart --env <name> --with-db`。
129
+
130
+ ## 重新认证
131
+
132
+ 如果 env 已经保存,只是登录态过期了,或者你想切换认证方式,可以重新认证:
133
+
134
+ ```bash
135
+ nb env auth
136
+ nb env auth prod
137
+ nb env auth prod --auth-type oauth
138
+ nb env auth prod --auth-type basic --username admin --password secret
139
+ nb env auth prod --auth-type token --access-token <api-key>
140
+ ```
141
+
142
+ 省略环境名时,CLI 会使用当前 env。认证完成后,CLI 会自动处理后续同步。
143
+
144
+ ## 移除环境
145
+
146
+ 如果你只想移除保存的 env 配置:
147
+
148
+ ```bash
149
+ nb env remove staging
150
+ ```
151
+
152
+ 如果是本地或 Docker 托管的 env,并且你还想一起清理本机上的运行资源和 storage 数据,可以加上 `--purge`:
153
+
154
+ ```bash
155
+ nb env remove test --purge
156
+ ```
157
+
158
+ 在非交互模式下,`nb env remove` 需要显式传入 `--force`:
159
+
160
+ ```bash
161
+ nb env remove test --purge --force
162
+ ```
163
+
164
+ `--purge` 只会清理当前机器上的 CLI 托管资源。对于远程 API env,它不会去删除远端服务本身。
165
+
166
+ ## 相关链接
167
+
168
+ - [`nb env` 命令参考](../../api/cli/env/index.md)
169
+ - [`nb env update`](../../api/cli/env/update.md)
170
+ - [`nb session` 命令参考](../../api/cli/session/index.md)
171
+ - [管理应用](./manage-app.md)
@@ -0,0 +1,86 @@
1
+ # 第三方插件安装与升级
2
+
3
+ 如果你拿到的是第三方插件包,通常来说先把它导入目标应用的 `storage/plugins`,然后先重启应用,再继续启用或验证插件是否生效。
4
+
5
+ ## 快速索引
6
+
7
+ | 我想要…… | 去哪里看 |
8
+ | --- | --- |
9
+ | 先切到目标 env,再开始导入或重启插件 | [先确认目标环境](#先确认目标环境) |
10
+ | 从远程压缩包、本地压缩包或 npm 导入第三方插件 | [用 `nb plugin import` 导入插件包](#用-nb-plugin-import-导入插件包) |
11
+ | 导入完成后让应用重新加载插件目录 | [`nb app restart`](../../api/cli/app/restart.md) |
12
+ | 第一次安装后正式启用插件 | [`nb plugin enable`](../../api/cli/plugin/enable.md) |
13
+ | 想确认插件是否已经出现在当前应用里 | [`nb plugin list`](../../api/cli/plugin/list.md) |
14
+ | 目标机器不能直接联网,只能手动上传 `.tgz` 再导入 | [不能直接联网时](#不能直接联网时) |
15
+
16
+ ## 先确认目标环境
17
+
18
+ 如果你本地管理了多个应用,先切到目标 env 再操作:
19
+
20
+ ```bash
21
+ nb env use app1
22
+ ```
23
+
24
+ ## 用 `nb plugin import` 导入插件包
25
+
26
+ `nb plugin import` 支持三类来源:远程压缩包、本地压缩包、npm 包名。这个命令只负责把插件导入 `storage/plugins`,不会自动启用插件。
27
+
28
+ 如果你已经拿到了插件包下载地址、本地文件路径,或者插件已经发布到 npm,可以执行:
29
+
30
+ ```bash
31
+ # 远程压缩包
32
+ nb plugin import https://github.com/nocobase/plugin-auth-cas/releases/download/v1.4.0/plugin-auth-cas-1.4.0.tgz
33
+
34
+ # 本地压缩包
35
+ nb plugin import /your/path/plugin-auth-cas-1.4.0.tgz
36
+
37
+ # npm 包名或 tag
38
+ nb plugin import @my-scope/plugin-auth-cas@beta
39
+ ```
40
+
41
+ 如果你用的是私有 npm 源,通常来说先登录,再指定 registry:
42
+
43
+ ```bash
44
+ npm login --registry=https://registry.example.com
45
+ nb plugin import @my-scope/plugin-auth-cas@beta --npm-registry=https://registry.example.com
46
+ ```
47
+
48
+ ## 导入之后先重启
49
+
50
+ 导入完成后,先重启目标应用:
51
+
52
+ ```bash
53
+ nb app restart
54
+ ```
55
+
56
+ 如果你没有先切换当前 env,也可以在命令里显式传入 `-e <env>`。
57
+
58
+ ## 重启之后再启用或验证
59
+
60
+ 如果这是第一次安装,重启后再启用插件:
61
+
62
+ ```bash
63
+ nb plugin enable @nocobase/plugin-auth-cas
64
+ ```
65
+
66
+ 第一次启用时会自动完成安装。
67
+
68
+ 如果插件已经启用,而你这次只是更新压缩包或重新导入一个新版本,通常来说重启完成后就可以继续验证插件是否正常工作,不需要再用 `upgrade` 的做法。
69
+
70
+
71
+ ## 不能直接联网时
72
+
73
+ 如果目标机器不能直接访问插件下载地址,可以先把 `.tgz` 文件上传到目标机器的任意目录,再在目标机器执行本地导入。
74
+
75
+ 比如:
76
+
77
+ ```bash
78
+ nb plugin import /your/path/plugin-auth-cas-1.4.0.tgz
79
+ nb app restart
80
+ ```
81
+
82
+ :::warning 注意
83
+
84
+ 这里不需要手动解压到 `storage/plugins`。`nb plugin import` 会自动把插件放到正确目录。
85
+
86
+ :::
@@ -0,0 +1,163 @@
1
+ ---
2
+ title: "Production Deployment"
3
+ description: "Deploy NocoBase in production with two final steps: enable app autostart and configure a reverse proxy."
4
+ keywords: "NocoBase,production deployment,nb app autostart,nb env proxy,Nginx,Caddy"
5
+ ---
6
+
7
+ # Production Deployment
8
+
9
+ If your NocoBase app is already running correctly on the server, production rollout usually only needs two more steps:
10
+
11
+ 1. Make sure the app starts automatically after the machine restarts
12
+ 2. Put a reverse proxy in front of the app for stable external access
13
+
14
+ In the NocoBase CLI, the main commands are:
15
+
16
+ - `nb app autostart`
17
+ - `nb env proxy`
18
+
19
+ This page gives the overall path first. For Nginx or Caddy details, continue to the corresponding subpages.
20
+
21
+ ## Step 1: Enable App Autostart
22
+
23
+ In production, the first priority is not the domain name. The first priority is making sure the service can recover reliably after a reboot, container recreation, or routine maintenance.
24
+
25
+ In the CLI, `nb app autostart` is a command group. The most commonly used commands are:
26
+
27
+ - `nb app autostart enable`
28
+ - `nb app autostart list`
29
+ - `nb app autostart run`
30
+
31
+ Enable autostart for the current env:
32
+
33
+ ```bash
34
+ nb app autostart enable
35
+ ```
36
+
37
+ If you want to target a different env explicitly:
38
+
39
+ ```bash
40
+ nb app autostart enable --env app1 --yes
41
+ ```
42
+
43
+ Then check which envs are marked for autostart:
44
+
45
+ ```bash
46
+ nb app autostart list
47
+ ```
48
+
49
+ After the system boots, run the following command to start every env that has autostart enabled:
50
+
51
+ ```bash
52
+ nb app autostart run
53
+ ```
54
+
55
+ If you want the underlying startup output for troubleshooting:
56
+
57
+ ```bash
58
+ nb app autostart run --verbose
59
+ ```
60
+
61
+ :::tip What this actually does
62
+
63
+ `nb app autostart enable` marks a CLI-managed env as allowed to start automatically.
64
+ `nb app autostart run` is the command that actually starts all envs that were marked for autostart.
65
+
66
+ In other words, in a real production setup you usually still need to wire `nb app autostart run` into your own system startup flow, such as `systemd`, a container platform startup script, or another host-level boot mechanism you already use.
67
+
68
+ :::
69
+
70
+ ### Scope
71
+
72
+ `nb app autostart` only applies to envs with a CLI-managed runtime on the current machine:
73
+
74
+ - `local`
75
+ - `docker`
76
+
77
+ If the env is only a remote API connection, or the app is not managed locally by the CLI on this machine, these commands are not the right tool for autostart.
78
+
79
+ ## Step 2: Configure a Reverse Proxy
80
+
81
+ Once the app can recover automatically, the next step is to handle the external entry point. In production, the reverse proxy usually takes care of:
82
+
83
+ - binding the domain name or public port
84
+ - forwarding HTTP and WebSocket traffic to NocoBase
85
+ - handling HTTPS, certificates, caching, or access control
86
+
87
+ In the NocoBase CLI, the recommended entry points are:
88
+
89
+ - `nb env proxy nginx`
90
+ - `nb env proxy caddy`
91
+
92
+ ### Default Approach
93
+
94
+ If your app is already saved as a CLI env and is a `local` or `docker` env, letting the CLI generate the proxy config is usually enough:
95
+
96
+ ```bash
97
+ nb env proxy nginx --env app1 --host app.example.com
98
+ nb env proxy caddy --env app1 --host app.example.com
99
+ ```
100
+
101
+ If the current env is already the target env, you can omit `--env`:
102
+
103
+ ```bash
104
+ nb env proxy nginx --host app.example.com
105
+ ```
106
+
107
+ The CLI helps cover details that are easy to miss in handwritten configs, such as:
108
+
109
+ - WebSocket forwarding
110
+ - entry and static asset paths for subpath deployments
111
+ - SPA fallback pages
112
+ - provider shared config files
113
+
114
+ ### When To Choose Nginx Or Caddy
115
+
116
+ You can usually decide like this:
117
+
118
+ | Scenario | Recommended |
119
+ | --- | --- |
120
+ | You already use Nginx for sites, caching, certificates, or access control | [Nginx](./reverse-proxy/nginx.md) |
121
+ | You already have a domain and want HTTPS working quickly with less TLS maintenance | [Caddy](./reverse-proxy/caddy.md) |
122
+ | You want the overall explanation of this command group first | [Production Reverse Proxy](./reverse-proxy/index.md) |
123
+
124
+ If you change env settings that affect the proxy result, such as `app-port` or `app-public-path`, remember to rerun the corresponding proxy subcommand.
125
+
126
+ ## Recommended Rollout Path
127
+
128
+ If you want the simplest production path, this order usually works well:
129
+
130
+ 1. Make sure the app can already start correctly on the server itself
131
+ 2. Run `nb app autostart enable`
132
+ 3. Add `nb app autostart run` to your system startup process
133
+ 4. Choose Nginx or Caddy and run the matching `nb env proxy` subcommand
134
+ 5. Verify external access through the final domain or public entry address
135
+
136
+ ## Quick Links
137
+
138
+ | I want to... | Read this |
139
+ | --- | --- |
140
+ | Start with the overall reverse proxy explanation | [Production Reverse Proxy](./reverse-proxy/index.md) |
141
+ | Keep using Nginx for the entry layer | [Nginx](./reverse-proxy/nginx.md) |
142
+ | Use Caddy for a faster HTTPS setup | [Caddy](./reverse-proxy/caddy.md) |
143
+ | Manage start, stop, logs, and upgrades | [Manage Apps](../operations/manage-app.md) |
144
+ | Read the `nb env proxy` CLI reference | [`nb env proxy`](../../api/cli/env/proxy/index.md) |
145
+
146
+ ## Related Commands
147
+
148
+ ```bash
149
+ # Enable autostart for one env
150
+ nb app autostart enable --env app1 --yes
151
+
152
+ # List autostart status
153
+ nb app autostart list
154
+
155
+ # Start all envs with autostart enabled
156
+ nb app autostart run
157
+
158
+ # Generate Nginx reverse proxy config
159
+ nb env proxy nginx --env app1 --host app.example.com
160
+
161
+ # Generate Caddy reverse proxy config
162
+ nb env proxy caddy --env app1 --host app.example.com
163
+ ```