@lobehub/lobehub 2.0.2 → 2.0.4

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 (97) hide show
  1. package/.github/ISSUE_TEMPLATE/1_bug_report.yml +0 -11
  2. package/CHANGELOG.md +51 -0
  3. package/README.md +9 -13
  4. package/README.zh-CN.md +6 -8
  5. package/apps/desktop/Development.md +1 -1
  6. package/changelog/v2.json +18 -0
  7. package/docker-compose/local/docker-compose.yml +2 -2
  8. package/docker-compose/local/grafana/docker-compose.yml +3 -3
  9. package/docker-compose/local/logto/docker-compose.yml +3 -4
  10. package/docker-compose/local/zitadel/.env.example +3 -4
  11. package/docker-compose/local/zitadel/.env.zh-CN.example +1 -2
  12. package/docker-compose/local/zitadel/docker-compose.yml +3 -3
  13. package/docker-compose/production/grafana/docker-compose.yml +3 -3
  14. package/docker-compose/production/logto/.env.example +7 -9
  15. package/docker-compose/production/logto/.env.zh-CN.example +7 -9
  16. package/docker-compose/production/logto/docker-compose.yml +3 -3
  17. package/docker-compose/production/zitadel/.env.example +4 -6
  18. package/docker-compose/production/zitadel/.env.zh-CN.example +3 -5
  19. package/docker-compose/production/zitadel/docker-compose.yml +3 -3
  20. package/docs/development/basic/folder-structure.mdx +1 -2
  21. package/docs/development/basic/folder-structure.zh-CN.mdx +1 -2
  22. package/docs/self-hosting/advanced/auth/legacy.mdx +1 -1
  23. package/docs/self-hosting/advanced/auth/legacy.zh-CN.mdx +1 -1
  24. package/docs/self-hosting/advanced/auth/nextauth-to-betterauth.mdx +4 -0
  25. package/docs/self-hosting/advanced/auth/nextauth-to-betterauth.zh-CN.mdx +4 -0
  26. package/docs/self-hosting/advanced/auth/providers/casdoor.mdx +8 -0
  27. package/docs/self-hosting/advanced/auth/providers/casdoor.zh-CN.mdx +8 -0
  28. package/docs/self-hosting/advanced/auth.mdx +28 -1
  29. package/docs/self-hosting/advanced/auth.zh-CN.mdx +29 -2
  30. package/docs/self-hosting/advanced/upstream-sync.mdx +5 -5
  31. package/docs/self-hosting/advanced/upstream-sync.zh-CN.mdx +5 -5
  32. package/docs/self-hosting/environment-variables/auth.mdx +2 -334
  33. package/docs/self-hosting/environment-variables/auth.zh-CN.mdx +2 -307
  34. package/docs/self-hosting/environment-variables/basic.mdx +1 -1
  35. package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +1 -1
  36. package/docs/self-hosting/environment-variables.mdx +1 -1
  37. package/docs/self-hosting/platform/docker-compose.mdx +837 -90
  38. package/docs/self-hosting/platform/docker-compose.zh-CN.mdx +809 -84
  39. package/docs/self-hosting/platform/docker.mdx +110 -111
  40. package/docs/self-hosting/platform/docker.zh-CN.mdx +103 -151
  41. package/docs/self-hosting/{server-database → platform}/dokploy.mdx +2 -2
  42. package/docs/self-hosting/{server-database → platform}/dokploy.zh-CN.mdx +2 -2
  43. package/docs/self-hosting/platform/repocloud.mdx +11 -10
  44. package/docs/self-hosting/platform/repocloud.zh-CN.mdx +13 -11
  45. package/docs/self-hosting/platform/sealos.mdx +79 -13
  46. package/docs/self-hosting/platform/sealos.zh-CN.mdx +92 -11
  47. package/docs/self-hosting/platform/vercel.mdx +323 -19
  48. package/docs/self-hosting/platform/vercel.zh-CN.mdx +318 -24
  49. package/docs/self-hosting/platform/zeabur.mdx +41 -37
  50. package/docs/self-hosting/platform/zeabur.zh-CN.mdx +34 -39
  51. package/docs/self-hosting/server-database.mdx +6 -6
  52. package/docs/self-hosting/server-database.zh-CN.mdx +5 -5
  53. package/locales/en-US/setting.json +2 -0
  54. package/locales/zh-CN/setting.json +2 -0
  55. package/package.json +2 -2
  56. package/packages/agent-runtime/src/agents/GeneralChatAgent.ts +18 -14
  57. package/packages/agent-runtime/src/types/generalAgent.ts +5 -4
  58. package/packages/types/src/user/preference.ts +2 -2
  59. package/scripts/_shared/checkDeprecatedAuth.js +16 -0
  60. package/src/features/ChatInput/ActionBar/Params/Controls.tsx +17 -1
  61. package/src/features/ModelSelect/index.tsx +1 -1
  62. package/src/libs/next/proxy/createRouteMatcher.test.ts +0 -8
  63. package/src/libs/trpc/middleware/userAuth.test.ts +0 -6
  64. package/src/locales/default/setting.ts +3 -0
  65. package/src/proxy.ts +0 -1
  66. package/src/server/routers/async/__tests__/caller.test.ts +2 -2
  67. package/src/server/routers/lambda/config/index.test.ts +0 -6
  68. package/src/server/services/agentRuntime/AgentRuntimeService.ts +4 -2
  69. package/src/store/chat/slices/aiChat/actions/streamingExecutor.ts +3 -0
  70. package/src/store/chat/slices/message/selectors/displayMessage.test.ts +21 -0
  71. package/src/store/chat/slices/message/selectors/displayMessage.ts +7 -2
  72. package/docs/self-hosting/platform/alibaba-cloud.mdx +0 -28
  73. package/docs/self-hosting/platform/alibaba-cloud.zh-CN.mdx +0 -25
  74. package/docs/self-hosting/platform/btpanel.mdx +0 -48
  75. package/docs/self-hosting/platform/btpanel.zh-CN.mdx +0 -51
  76. package/docs/self-hosting/platform/netlify.mdx +0 -91
  77. package/docs/self-hosting/platform/netlify.zh-CN.mdx +0 -86
  78. package/docs/self-hosting/platform/railway.mdx +0 -29
  79. package/docs/self-hosting/platform/railway.zh-CN.mdx +0 -29
  80. package/docs/self-hosting/platform/tencentcloud-lighthouse.mdx +0 -29
  81. package/docs/self-hosting/platform/tencentcloud-lighthouse.zh-CN.mdx +0 -26
  82. package/docs/self-hosting/server-database/docker-compose.mdx +0 -879
  83. package/docs/self-hosting/server-database/docker-compose.zh-CN.mdx +0 -854
  84. package/docs/self-hosting/server-database/docker.mdx +0 -154
  85. package/docs/self-hosting/server-database/docker.zh-CN.mdx +0 -153
  86. package/docs/self-hosting/server-database/netlify.mdx +0 -13
  87. package/docs/self-hosting/server-database/netlify.zh-CN.mdx +0 -16
  88. package/docs/self-hosting/server-database/railway.mdx +0 -13
  89. package/docs/self-hosting/server-database/railway.zh-CN.mdx +0 -15
  90. package/docs/self-hosting/server-database/repocloud.mdx +0 -33
  91. package/docs/self-hosting/server-database/repocloud.zh-CN.mdx +0 -32
  92. package/docs/self-hosting/server-database/sealos.mdx +0 -97
  93. package/docs/self-hosting/server-database/sealos.zh-CN.mdx +0 -112
  94. package/docs/self-hosting/server-database/vercel.mdx +0 -344
  95. package/docs/self-hosting/server-database/vercel.zh-CN.mdx +0 -337
  96. package/docs/self-hosting/server-database/zeabur.mdx +0 -76
  97. package/docs/self-hosting/server-database/zeabur.zh-CN.mdx +0 -67
@@ -1,43 +1,337 @@
1
1
  ---
2
- title: 在 Vercel 上部署 LobeHub
3
- description: 学习如何在 Vercel 上一键部署 LobeHub,准备 OpenAI API Key,点击按钮进行部署,绑定自定义域名,自动同步更新等。
2
+ title: 在 Vercel 上部署 LobeHub 的服务端数据库版本
3
+ description: 本文详细介绍如何在 Vercel 中部署服务端数据库版 LobeHub,包括数据库配置、身份验证服务配置和 S3 存储服务的设置步骤。
4
4
  tags:
5
- - Vercel
6
- - 部署指引
7
- - LobeHub
8
- - OpenAI API Key
9
- - 自定义域名
10
- - 自动同步更新
5
+ - 服务端数据库
6
+ - Postgres
7
+ - Better Auth
8
+ - S3存储服务
9
+ - Vercel部署
10
+ - 数据库配置
11
+ - 身份验证服务
12
+ - 环境变量配置
11
13
  ---
12
14
 
13
- # Vercel 部署指引
15
+ # Vercel 上部署服务端数据库版
14
16
 
15
- 如果想在 Vercel 上部署 LobeHub,可以按照以下步骤进行操作:
17
+ 本文将详细介绍如何在 Vercel 中部署服务端数据库版 LobeHub,包括: 1)数据库配置;2)身份验证服务配置;3) S3 存储服务的设置步骤。
16
18
 
17
- ## Vercel 部署流程
19
+ <Callout type={'warning'}>
20
+ 进行后续操作前,请务必确认以下事项:
21
+
22
+ - 导出所有数据,部署服务端数据库后,原有用户数据无法自动迁移,只能提前备份后进行手动导入!
23
+ - 配置服务端数据库所需要的环境变量时,需全部填入后再进行部署,否则可能遭遇数据库迁移问题!
24
+ </Callout>
25
+
26
+ ## 一、 配置数据库
18
27
 
19
28
  <Steps>
20
- ### 点击下方按钮进行部署
29
+ ### 准备服务端数据库实例,获取连接 URL
30
+
31
+ 在部署之前,请确保你已经准备好 Postgres 数据库实例,你可以选择以下任一方式:
32
+
33
+ - `A.` 使用 Vercel / Neon 等 Serverless Postgres 实例;
34
+ - `B.` 使用 Docker 等自部署 Postgres 实例。
35
+
36
+ 两者的配置方式略有不同,在下一步会有所区分。
37
+
38
+ ### 在 Vercel 中添加环境变量
39
+
40
+ 在 Vercel 的部署环境变量中,添加 `DATABASE_URL` 等环境变量,将上一步准备好的 Postgres 数据库连接 URL 填入其中。数据库连接 URL 的通常格式为 `postgres://username:password@host:port/database`。
41
+
42
+ <Tabs items={['Serverless Postgres', 'Node Postgres']}>
43
+ <Tab>
44
+ <Callout type={'warning'}>
45
+ 请确认您的供应商所提供的 `Postgres` 类型,若为 `Node Postgres`,请切换到 `Node Postgres` Tab 。
46
+ </Callout>
47
+
48
+ Serverless Postgres 需要填写的变量如下:
49
+
50
+ ```shell
51
+ # Serverless Postgres DB Url
52
+ DATABASE_URL=
53
+ ```
54
+
55
+ 在 Vercel 中填写的示例如下:
56
+
57
+ <Image alt={'添加 Serverless Postgres DATABASE_URL'} src={'/blog/assets28616219/d4a710cd-6404-4196-90d0-cd08ca385074.webp'} />
58
+ </Tab>
59
+
60
+ <Tab>
61
+ Node Postgres 需要填写的变量如下:
62
+
63
+ ```shell
64
+ # Node Postgres DB Url
65
+ DATABASE_URL=
21
66
 
22
- [![][deploy-button-image]][deploy-link]
67
+ # 指定 Postgres database driver 为 node
68
+ DATABASE_DRIVER=node
69
+ ```
23
70
 
24
- 直接使用 GitHub 账号登录即可完成部署。
71
+ Vercel 中填写的示例如下:
25
72
 
26
- ### 部署完毕后,即可开始使用
73
+ <Image alt={'添加 Node Postgres DATABASE_URL'} src={'/blog/assets28616219/1c689738-809b-4199-b305-ba5770d39da7.webp'} />
74
+ </Tab>
75
+ </Tabs>
27
76
 
28
- ### 绑定自定义域名(可选)
77
+ <Callout type={'info'}>
78
+ 如果希望连接数据库时启用 SSL
79
+ ,请自行参考[链接](https://stackoverflow.com/questions/14021998/using-psql-to-connect-to-postgresql-in-ssl-mode)进行设置
80
+ </Callout>
29
81
 
30
- Vercel 分配的域名 DNS 在某些区域被污染了,绑定自定义域名即可直连。
82
+ ### 添加 `KEY_VAULTS_SECRET` 环境变量
83
+
84
+ 在完成数据库 `DATABASE_URL` 环境变量添加后,需要添加一个 `KEY_VAULTS_SECRET` 环境变量。该变量用于加密用户存储的 apikey 等敏感信息。点击下方按钮一键生成:
85
+
86
+ <GenerateSecret envName="KEY_VAULTS_SECRET" />
87
+
88
+ 同样需要将其添加到 Vercel 环境变量中。
89
+
90
+ ### 添加 `APP_URL` 环境变量
91
+
92
+ 该部分最后需要添加 `APP_URL` 环境变量,用于指定 LobeHub 应用的 URL 地址。
31
93
  </Steps>
32
94
 
33
- ## 自动同步更新
95
+ ## 二、 配置身份验证服务
96
+
97
+ 服务端数据库需要搭配用户身份验证服务才可以正常使用。因此需要配置对应的身份验证服务。
98
+
99
+ <Steps>
100
+ ### 添加身份验证环境变量
101
+
102
+ 在 Vercel 的部署环境变量中,添加以下环境变量以启用身份验证(基于 [Better Auth](https://www.better-auth.com)):
103
+
104
+ 点击下方按钮一键生成 `AUTH_SECRET`(会话加密密钥):
105
+
106
+ <GenerateSecret envName="AUTH_SECRET" />
107
+
108
+ 同时需要配置 `JWKS_KEY` 环境变量,用于签名和验证 JWT。点击下方按钮一键生成:
109
+
110
+ <GenerateJWKSKey />
111
+
112
+ 配置这些变量后,用户即可使用邮箱和密码注册登录。
34
113
 
35
- 如果你根据上述中的一键部署步骤部署了自己的项目,你可能会发现总是被提示 “有可用更新”。这是因为 Vercel 默认为你创建新项目而非 fork 本项目,这将导致无法准确检测更新。
114
+ <Callout type={'info'}>
115
+ 如需 SSO 登录、魔法链接登录、邮箱验证等高级功能,请参阅 [身份验证服务](/zh/docs/self-hosting/advanced/auth)。
116
+ </Callout>
36
117
 
37
- <Callout>
38
- 我们建议按照 [📘 LobeHub 自部署保持更新](/zh/docs/self-hosting/advanced/upstream-sync)
39
- 步骤重新部署。
118
+ ### 在 Vercel 中添加公、私钥环境变量
119
+
120
+ 在 Vercel 的部署环境变量中,添加 `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` 和 `CLERK_SECRET_KEY` 环境变量。你可以在菜单中点击「API Keys」,然后复制对应的值填入 Vercel 的环境变量中。
121
+
122
+ <Image alt={'在 Clerk 中找到对应的公私钥环境变量'} src={'/blog/assets28616219/89883703-7a1a-4a11-b944-5d804544e57c.webp'} />
123
+
124
+ 此步骤所需的环境变量如下:
125
+
126
+ ```shell
127
+ NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
128
+ CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
129
+ ```
130
+
131
+ 添加上述变量到 Vercel 中:
132
+
133
+ <Image alt={'在 Vercel 中添加 Clerk 公私钥环境变量'} src={'/blog/assets28616219/2bfa13df-6e20-4768-97c0-4dad06c85a2f.webp'} />
134
+
135
+ ### 在 Clerk 中创建并配置 Webhook
136
+
137
+ 由于我们让 Clerk 完全接管用户鉴权与管理,因此我们需要在 Clerk 用户生命周期变更时(创建、更新、删除)中通知我们的应用并存储落库。我们通过 Clerk 提供的 Webhook 来实现这一诉求。
138
+
139
+ 我们需要在 Clerk 的 Webhooks 中添加一个端点(Endpoint),告诉 Clerk 当用户发生变更时,向这个端点发送通知。
140
+
141
+ <Image alt={'Clerk 添加 Webhooks 端点'} src={'/blog/assets28616219/f50f47fb-5e8e-4930-bf4e-8cf6f5b8afb9.webp'} />
142
+
143
+ 在 endpoint 中填写你的 Vercel 项目的 URL,如 `https://your-project.vercel.app/api/webhooks/clerk`。然后在订阅事件(Subscribe to events)中,勾选 user 的三个事件(`user.created` 、`user.deleted`、`user.updated`),然后点击创建。
144
+
145
+ <Callout type={'warning'}>URL 的`https://`不可缺失,须保持 URL 的完整性</Callout>
146
+
147
+ <Image alt={'添加 Clerk Webhooks 时,配置 URL 和用户事件'} src={'/blog/assets28616219/0249ea56-ab17-4aa9-a56c-9ebd556c2645.webp'} />
148
+
149
+ ### 将 Webhook 秘钥添加到 Vercel 环境变量
150
+
151
+ 创建完毕后,可以在右下角找到该 Webhook 的秘钥:
152
+
153
+ <Image alt={'查看 Clerk Webhooks 秘钥'} src={'/blog/assets28616219/fab4abb2-584b-49de-9340-813382951635.webp'} />
154
+
155
+ 这个秘钥所对应的环境变量名为 `CLERK_WEBHOOK_SECRET`:
156
+
157
+ ```shell
158
+ CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
159
+ ```
160
+
161
+ 将其添加到 Vercel 的环境变量中:
162
+
163
+ <Image alt={'在 Vercel 中 添加 Clerk Webhooks 秘钥'} src={'/blog/assets28616219/5fdc9479-007f-46ab-9d6e-a9603e949116.webp'} />
164
+ </Steps>
165
+
166
+ 这样,你已经成功配置了身份验证服务。接下来我们将配置 S3 存储服务。
167
+
168
+ ## 三、 配置 S3 存储服务
169
+
170
+ 在服务端数据库中我们需要配置 S3 存储服务来存储文件。
171
+
172
+ <Callout type={'info'}>
173
+ 在本文,S3 所指代的是指兼容 S3 存储方案,即支持 Amazon S3 API 的对象存储系统,常见例如 Cloudflare
174
+ R2 、阿里云 OSS 等均支持 S3 兼容 API。
40
175
  </Callout>
41
176
 
42
- [deploy-button-image]: https://vercel.com/button
43
- [deploy-link]: https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat&project-name=lobe-chat&repository-name=lobe-chat
177
+ <Steps>
178
+ ### 配置并获取 S3 存储桶
179
+
180
+ 你需要前往你的 S3 服务提供商(如 AWS S3、Cloudflare R2 等)并创建一个新的存储桶(Bucket)。接下来以 Cloudflare R2 为例,介绍创建流程。
181
+
182
+ 下图是 Cloudflare R2 的界面:
183
+
184
+ <Image alt={'Cloudflare R2 存储界面'} src={'/blog/assets28616219/41f7f677-0153-4a96-b849-5ac9b7ebefee.webp'} />
185
+
186
+ 创建存储桶时将指定其名称,然后点击创建。
187
+
188
+ <Image alt={'R2 创建存储桶'} src={'/blog/assets28616219/9c0d184c-3169-40fa-9115-011cfffb9ca7.webp'} />
189
+
190
+ ### 获取存储桶相关环境变量
191
+
192
+ 在 R2 存储桶的设置中,可以看到桶配置的信息:
193
+
194
+ <Image alt={'查看存储桶的相关信息'} src={'/blog/assets28616219/2ceb210c-eca0-4439-ba27-8734d4ebb3ee.webp'} />
195
+
196
+ 其对应的环境变量为:
197
+
198
+ ```shell
199
+ # 存储桶的名称
200
+ S3_BUCKET=LobeHub
201
+ # 存储桶的请求端点(注意此处链接的路径带存储桶名称,必须删除该路径,或使用申请 S3 API token 页面所提供的链接)
202
+ S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
203
+ # 存储桶对外的访问域名
204
+ S3_PUBLIC_DOMAIN=https://s3-for-LobeHub.your-domain.com
205
+ ```
206
+
207
+ <Callout type={'warning'}>`S3_ENDPOINT`必须删除其路径,否则会无法访问所上传文件</Callout>
208
+
209
+ ### 获取 S3 密钥环境变量
210
+
211
+ 你需要获取 S3 的访问密钥,以便 LobeHub 的服务端有权限访问 S3 存储服务。在 R2 中,你可以在账户详情中配置访问密钥:
212
+
213
+ <Image alt={'查看存储桶的访问秘钥'} src={'/blog/assets28616219/be0c95c0-6693-44ee-a490-7e8dfaa8b34d.webp'} />
214
+
215
+ 点击右上角按钮创建 API token,进入创建 API Token 页面
216
+
217
+ <Image alt={'创建对应 API token'} src={'/blog/assets28616219/7b0ea46c-5157-40a8-888f-f47664a4884f.webp'} />
218
+
219
+ 鉴于我们的服务端数据库需要读写 S3 存储服务,因此权限需要选择`对象读与写`,然后点击创建。
220
+
221
+ <Image alt={'配置 API token 权限'} src={'/blog/assets28616219/d6f5a918-7b50-4d6e-83a6-3894ab930ddf.webp'} />
222
+
223
+ 创建完成后,就可以看到对应的 S3 API token
224
+
225
+ <Image alt={'复制 API token'} src={'/blog/assets28616219/763b18f9-2b5f-44bb-a479-9b56d46f7397.webp'} />
226
+
227
+ 其对应的环境变量为:
228
+
229
+ ```shell
230
+ S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
231
+ S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
232
+ ```
233
+
234
+ ### 在 Vercel 中添加对应的环境变量
235
+
236
+ 不同 S3 服务商获取所需环境变量的步骤可能有所不同,但最终获得到的环境变量应该都是一致的:
237
+
238
+ <Callout type={'warning'}>URL 的`https://`不可缺失,须保持 URL 的完整性</Callout>
239
+
240
+ ```shell
241
+ # S3 秘钥
242
+ S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
243
+ S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
244
+
245
+ # 存储桶的名称
246
+ S3_BUCKET=LobeHub
247
+ # 存储桶的请求端点
248
+ S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
249
+ # 存储桶对外的访问域名
250
+ S3_PUBLIC_DOMAIN=https://s3-dev.your-domain.com
251
+
252
+ # 桶的区域,如 us-west-1,一般来说不需要添加,但某些服务商则需要配置
253
+ # S3_REGION=us-west-1
254
+ ```
255
+
256
+ 然后将上述环境变量填入 Vercel 的环境变量中:
257
+
258
+ <Image alt={'在 Vercel 中添加 S3 的环境变量'} src={'/blog/assets28616219/cd74152d-0ae8-44fd-b815-3307c56a3c18.webp'} />
259
+
260
+ ### 配置跨域
261
+
262
+ 由于 S3 存储服务往往是一个独立的网址,因此需要配置跨域访问。
263
+
264
+ 在 R2 中,你可以在存储桶的设置中找到跨域配置:
265
+
266
+ <Image alt={'Cloudflare R2 的跨域设置'} src={'/blog/assets28616219/ab008be7-26b2-4b78-8bd9-24301bf34d23.webp'} />
267
+
268
+ 添加跨域规则,允许你的域名(在上文是 `https://your-project.vercel.app`)来源的请求:
269
+
270
+ <Image alt={'配置允许你的站点域名'} src={'/blog/assets28616219/dfcc2cb3-2958-4498-a8a4-51bec584fe7d.webp'} />
271
+
272
+ 示例配置如下:
273
+
274
+ ```json
275
+ [
276
+ {
277
+ "AllowedOrigins": ["https://your-project.vercel.app"],
278
+ "AllowedMethods": ["GET", "PUT", "HEAD", "POST", "DELETE"],
279
+ "AllowedHeaders": ["*"]
280
+ }
281
+ ]
282
+ ```
283
+
284
+ 配置后点击保存即可。
285
+ </Steps>
286
+
287
+ ## 四、部署并验证
288
+
289
+ 通过上述步骤之后,我们应该就完成了服务端数据库的配置。接下来我们可以将 LobeHub 部署到 Vercel 上,然后访问你的 Vercel 链接,验证服务端数据库是否正常工作。
290
+
291
+ <Steps>
292
+ ### 重新部署最新的 commit
293
+
294
+ 配置好环境变量后,你需要重新部署最新的 commit,并等待部署完成。
295
+
296
+ <Image alt={'重新部署最新的 commit'} src={'/blog/assets28616219/b3a78112-adc8-4837-b4e3-48f67058f16e.webp'} />
297
+
298
+ ### 检查功能是否正常
299
+
300
+ 如果你点击左上角登录,可以正常显示登录弹窗,那么说明你已经配置成功了,尽情享用吧~
301
+
302
+ <Image alt={'用户登录弹窗'} src={'/blog/assets28616219/da84edc3-46f7-4e2b-a0cd-dc33a98bf5cb.webp'} />
303
+
304
+ <Image alt={'登录成功状态'} src={'/blog/assets28616219/9cb5150d-6e1e-4c59-9a18-4e418dce1a5d.webp'} />
305
+ </Steps>
306
+
307
+ ## 附录
308
+
309
+ ### 服务端数据库环境变量一览
310
+
311
+ 为方便一键复制,在此汇总配置服务端数据库所需要的环境变量:
312
+
313
+ ```shell
314
+ APP_URL=https://your-project.com
315
+
316
+ # Postgres 数据库 URL
317
+ DATABASE_URL=
318
+ KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
319
+
320
+ # 身份验证
321
+ AUTH_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
322
+ JWKS_KEY='{"keys":[...]}'
323
+
324
+ # S3 相关配置
325
+ # S3 秘钥
326
+ S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
327
+ S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
328
+
329
+ # 存储桶的名称
330
+ S3_BUCKET=LobeHub
331
+ # 存储桶的请求端点
332
+ S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
333
+ # 存储桶对外的访问域名
334
+ S3_PUBLIC_DOMAIN=https://s3-for-LobeHub.your-domain.com
335
+ # 桶的区域,如 us-west-1,一般来说不需要添加,但某些服务商则需要配置
336
+ # S3_REGION=us-west-1
337
+ ```
@@ -1,72 +1,76 @@
1
1
  ---
2
- title: Deploy LobeHub on Zeabur
2
+ title: Deploying LobeHub Database on Zeabur
3
3
  description: >-
4
4
  Learn how to deploy LobeHub on Zeabur with ease. Follow the provided steps to
5
5
  set up your chat application seamlessly.
6
6
  tags:
7
7
  - Deploy LobeHub
8
8
  - Zeabur Deployment
9
+ - OpenAI API Key
9
10
  - Custom Domain Binding
10
11
  ---
11
12
 
12
- # Deploy LobeHub with Zeabur
13
+ # Deploying LobeHub Database on Zeabur
13
14
 
14
- If you want to deploy LobeHub on Zeabur, you can follow the steps below:
15
+ <Callout type="info">
16
+ This article assumes that you are familiar with the basic principles and processes of deploying
17
+ the LobeHub server database version, so it only includes content related to core environment
18
+ variable configuration. If you are not familiar with the deployment principles of the LobeHub
19
+ server database version, please refer to [Deploying Server
20
+ Database](/docs/self-hosting/server-database) first.
21
+ </Callout>
15
22
 
16
- ## Zeabur Deployment Process
23
+ The template on Zeabur includes 4 services:
17
24
 
18
- <Steps>
19
- ### Click the button below to deploy
25
+ - Logto for authrization.
26
+ - PostgreSQL with Vector plugin for data storage and indexing.
27
+ - MinIO for image storage.
28
+ - LobeHub database version.
20
29
 
21
- [![][deploy-button-image]][deploy-link]
30
+ ## Deploying on Zeabur
22
31
 
23
- ### Once deployed, you can start using it
32
+ Here is the process for deploying the LobeHub server database version on Zeabur:
24
33
 
25
- ### Bind a custom domain (optional)
34
+ <Steps>
35
+ ### Go to the template page on Zeabur
26
36
 
27
- You can use the subdomain provided by Zeabur, or choose to bind a custom domain. Currently, the domains provided by Zeabur have not been contaminated, and most regions can connect directly.
28
- </Steps>
37
+ Go to the [LobeHub Database template page](https://zeabur.com/templates/RRSPSD) on Zeabur and click on the "Deploy" button.
29
38
 
30
- # Deploy LobeHub with Zeabur as serverless function
39
+ ### Fill in the required environment variables
31
40
 
32
- > Note: There are still issues with [middlewares and rewrites of next.js on Zeabur](https://github.com/lobehub/lobe-chat/pull/2775?notification_referrer_id=NT_kwDOAdi2DrQxMDkyODQ4MDc2NTozMDk3OTU5OA#issuecomment-2146713899), use at your own risk!
41
+ After you click on the "Deploy" button, you will see a modal pop-up where you can fill in the required environment variables.
33
42
 
34
- Since Zeabur does NOT officially support FREE users deploy containerized service, you may wish to deploy LobeHub as a serverless function service. To deploy LobeHub as a serverless function service on Zeabur, you can follow the steps below:
43
+ Here are the environment variables you need to fill in:
35
44
 
36
- ## Zeabur Deployment Process
45
+ - OpenAI API key: Your OpenAI API key to get responses from OpenAI.
37
46
 
38
- <Steps>
39
- ### Fork LobeHub
47
+ - LobeHub Domain: A free subdomain with `.zeabur.app` suffix.
40
48
 
41
- ### Add Zeabur pack config file
49
+ - MinIO Public Domain: A free subdomain with `.zeabur.app` suffix for yout MinIO web port to enable public access for the uploaded files.
42
50
 
43
- Add a `zbpack.json` configuration file with the following content to the root dir of your fork:
51
+ - Logto Console Domain: A free subdomain with `.zeabur.app` suffix for your Logto console.
44
52
 
45
- ```json
46
- {
47
- "ignore_dockerfile": true,
48
- "serverless": true
49
- }
50
- ```
53
+ - Logto API Domain: A free subdomain with `.zeabur.app` suffix for your Logto api.
51
54
 
52
- ### Login to your [Zeabur dashboard](https://dash.zeabur.com)
55
+ ### Select a region and deploy
53
56
 
54
- If you do not already have an account, you will need to register one.
57
+ After you fill all the required environment variables, select a region where you want to deploy your LobeHub Database and click on the "Deploy" button.
55
58
 
56
- ### Create a project and service
59
+ You will see another modal pop-up where you can see the deployment progress.
57
60
 
58
- Create a project, then create a service under this project.
61
+ ### Configure Logto
59
62
 
60
- ### Link your fork of LobeHub to the just created Zeabur service.
63
+ After the deployment is done, you need to configure your Logto service to enable authrization.
61
64
 
62
- When adding service, choose github. This may triger a oAuth depend on varies factors like how you login to Zeabur and if you have already authorized Zeabur to access all your repos
65
+ Access your Logto console with the console domain you just binded, and then create a `Next.js 14(App router)` application to get the client ID and client secret, and fill in the cors and callback URLs. You can check [this document](../advanced/auth.mdx) for a more detailed guide.
63
66
 
64
- ### Bind a custom domain (optional)
67
+ Fill in those variables into your LobeHub service on Zeabur, here is a more detailed guide for [editing environment variables on Zeabur](https://zeabur.com/docs/deploy/variables).
65
68
 
66
- You can create a subdomain provided by Zeabur, or choose to bind a custom domain. Currently, the domains provided by Zeabur have not been contaminated, and most regions can connect directly.
69
+ For detailed configuration of Logto, refer to [this document](/docs/self-hosting/advanced/auth/providers/logto).
67
70
 
68
- ### Zeabur shall start auto build and you should be able to access it by the domain of your choice after a while.
69
- </Steps>
71
+ ### Access your LobeHub Instance
72
+
73
+ Press on the `LobeHub-Database` and you can see the public domain you just created, click on it to access your LobeHub Database.
70
74
 
71
- [deploy-button-image]: https://zeabur.com/button.svg
72
- [deploy-link]: https://zeabur.com/templates/VZGGTI
75
+ You can also bind a custom domain for your services if you want, here is a guide on how to [bind a custom domain on Zeabur](https://zeabur.com/docs/deploy/domain-binding).
76
+ </Steps>
@@ -9,64 +9,59 @@ tags:
9
9
  - 自定义域名
10
10
  ---
11
11
 
12
- # 使用 Zeabur 部署
12
+ # 使用 Zeabur 部署 LobeHub 数据库版
13
13
 
14
- 如果想在 Zeabur 上部署 LobeHub,可以按照以下步骤进行操作:
14
+ <Callout type="info">
15
+ 本文假设你已经熟悉 LobeHub
16
+ 服务器数据库版的部署基本原理和流程,因此只包含与核心环境变量配置相关的内容。如果你对 LobeHub
17
+ 服务器数据库版的部署原理不熟悉,请先参考[部署服务器数据库](/zh/docs/self-hosting/server-database)。
18
+ </Callout>
15
19
 
16
- ## Zeabur 部署流程
20
+ Zeabur 的模板中总共包含有以下四个服务:
17
21
 
18
- <Steps>
19
- ### 点击下方按钮进行部署
20
-
21
- [![][deploy-button-image]][deploy-link]
22
-
23
- ### 部署完毕后,即可开始使用
24
-
25
- ### 绑定自定义域名(可选)
22
+ - Logto 提供身份校验
23
+ - 带有 Vector 插件的 PostgreSQL 来做数据存储和向量化
24
+ - MinIO 作为对象存储
25
+ - LobeHub Database 的实例
26
26
 
27
- 你可以使用 Zeabur 提供的子域名,也可以选择绑定自定义域名。目前 Zeabur 提供的域名还未被污染,大多数地区都可以直连。
28
- </Steps>
27
+ ## Zeabur 上部署
29
28
 
30
- # 使用 Zeabur LobeHub 部署为无服务器函数
29
+ 这里是在 Zeabur 上部署 LobeHub 服务器数据库版的流程:
31
30
 
32
- > **注意:** 仍然存在关于 [Zeabur 上 next.js 的中间件和重写问题](https://github.com/lobehub/lobe-chat/pull/2775?notification_referrer_id=NT_kwDOAdi2DrQxMDkyODQ4MDc2NTozMDk3OTU5OA#issuecomment-2146713899),请自担风险!
31
+ <Steps>
32
+ ### 前往 Zeabur 上的模板页面
33
33
 
34
- 由于 Zeabur 并未官方支持免费用户部署容器化服务,您可能希望将 LobeHub 部署为无服务器函数服务。要在 Zeabur 上将 LobeHub 部署为无服务器函数服务,您可以按照以下步骤操作:
34
+ 前往 [Zeabur 上的 LobeHub 数据库模板页面](https://zeabur.com/templates/RRSPSD) 并点击 "Deploy" 按钮。
35
35
 
36
- ## Zeabur 部署流程
36
+ ### 填写必要的环境变量
37
37
 
38
- <Steps>
39
- ### Fork LobeHub
38
+ 在你点击 “部署 “按钮后,你会看到一个模态弹窗,你可以在这里填写必要的环境变量。
40
39
 
41
- ### 添加 Zeabur 打包配置文件
40
+ 以下是你需要填写的环境变量:
42
41
 
43
- 在您的分支的根目录下添加一个 `zbpack.json` 配置文件,内容如下:
42
+ - OpenAI API key: 你的 OpenAI API key 用于获取模型的访问权限。
43
+ - LobeHub Domain: 一个免费的 `.zeabur.app` 后缀的域名。
44
+ - MinIO Public Domain: 一个免费的 `.zeabur.app` 后缀的域名为了暴露 MinIO 服务以公开访问资源。
45
+ - Logto Console Domain: 一个免费的 `.zeabur.app` 后缀的域名来访问 Logto 的控制台。
46
+ - Logto API Domain: 一个免费的 `.zeabur.app` 后缀的域名来访问 Logto 的 API。
44
47
 
45
- ```json
46
- {
47
- "ignore_dockerfile": true,
48
- "serverless": true
49
- }
50
- ```
48
+ ### 选择一个区域并部署
51
49
 
52
- ### 登录到您的 [Zeabur 仪表板](https://dash.zeabur.com)
50
+ 在你填写完所有必要的环境变量后,选择一个你想要部署 LobeHub 数据库的区域并点击 “部署” 按钮。
53
51
 
54
- 如果您尚未拥有一个账号,您需要注册一个。
52
+ 你会看到另一个模态弹窗,你可以在这里看到部署的进度。
55
53
 
56
- ### 创建项目与服务。
54
+ ### 配置 Logto
57
55
 
58
- 创建一个项目,并再这个项目下新建一个服务。
56
+ 当部署完成后,你会被自动导航到你在 Zeabur 控制台上刚刚创建的项目。你需要再进一步配置你的 Logto 服务。
59
57
 
60
- ### 将您的 LobeHub 分支链接到刚创建的 Zeabur 服务。
58
+ 使用你刚绑定的域名来访问你的 Logto 控制台,创建一个新项目以获得对应的客户端 ID 与密钥,将它们填入你的 LobeHub 服务的变量中。关于如何填入变量,可以参照 [Zeabur 的官方文档](https://zeabur.com/docs/deploy/variables)。
61
59
 
62
- 在添加服务时,选择 github。这可能会触发一个 oAuth,取决于诸如您如何登录到 Zeabur 以及您是否已经授权 Zeabur 访问所有您的存储库等各种因素。
60
+ Logto 的详细配置可以参考[这篇文档](/zh/docs/self-hosting/advanced/auth/providers/logto)。
63
61
 
64
- ### 绑定自定义域名(可选)
62
+ ### 访问你的 LobeHub
65
63
 
66
- 您可以创建 Zeabur 提供的子域名,或选择绑定自定义域名。目前,Zeabur 提供的域名尚未受到污染,大多数地区可以直接连接。
64
+ 按下 `LobeHub-Database` 你会看到你刚刚创建的公共域名,点击它以访问你的 LobeHub 数据库。
67
65
 
68
- ### Zeabur 将开始自动构建,您应该可以在一段时间后通过您选择的域名访问它。
66
+ 你可以选择绑定一个自定义域名,这里有一个关于如何在 Zeabur 上[绑定自定义域名](https://zeabur.com/docs/deploy/domain-binding)的指南。
69
67
  </Steps>
70
-
71
- [deploy-button-image]: https://zeabur.com/button.svg
72
- [deploy-link]: https://zeabur.com/templates/VZGGTI
@@ -23,7 +23,7 @@ This guide will introduce the process and principles of deploying the server-sid
23
23
 
24
24
  If you are already familiar with the complete principles, you can quickly get started by checking the deployment guides for each platform:
25
25
 
26
- <PlatformCards urlPrefix={'server-database'} />
26
+ <PlatformCards urlPrefix={'platform'} />
27
27
 
28
28
  ---
29
29
 
@@ -54,7 +54,7 @@ Since we support file-based conversations/knowledge base conversations, we need
54
54
  For server-side database deployment scenarios, you need to set `NEXT_PUBLIC_SERVICE_MODE` to `server`.
55
55
 
56
56
  <Callout type={'info'}>
57
- In the official `lobe-chat-database` Docker image, this environment variable is already set to
57
+ In the official `lobehub` Docker image, this environment variable is already set to
58
58
  `server` by default. Therefore, if you deploy using the Docker image, you do not need to configure
59
59
  this environment variable again.
60
60
  </Callout>
@@ -82,7 +82,7 @@ Since we support file-based conversations/knowledge base conversations, we need
82
82
  To streamline deployment, we have set default values based on the characteristics of different platforms:
83
83
 
84
84
  - On the Vercel platform, `DATABASE_DRIVER` defaults to `neon`;
85
- - In our provided Docker image `lobe-chat-database`, `DATABASE_DRIVER` defaults to `node`.
85
+ - In our provided Docker image `lobehub`, `DATABASE_DRIVER` defaults to `node`.
86
86
 
87
87
  Therefore, if you follow the standard deployment methods below, you do not need to manually configure the `DATABASE_DRIVER` environment variable:
88
88
 
@@ -95,7 +95,7 @@ Since we support file-based conversations/knowledge base conversations, we need
95
95
 
96
96
  <Callout type={'info'}>
97
97
  You can generate a random 32-character string as the value of `KEY_VAULTS_SECRET` using `openssl
98
- rand -base64 32`.
98
+ rand -base64 32`.
99
99
  </Callout>
100
100
  </Steps>
101
101
 
@@ -132,7 +132,7 @@ NextAuth is an open-source authentication library that supports multiple identit
132
132
  For information on configuring NextAuth, you can refer to the [Authentication](/docs/self-hosting/advanced/authentication) documentation.
133
133
 
134
134
  <Callout type={'tip'}>
135
- In the official Docker image `lobe-chat-database`, we recommend using NextAuth as the
135
+ In the official Docker image `lobehub`, we recommend using NextAuth as the
136
136
  authentication service.
137
137
  </Callout>
138
138
 
@@ -154,4 +154,4 @@ For detailed configuration guidelines on S3, please refer to [S3 Object Storage]
154
154
 
155
155
  The above is a detailed explanation of configuring LobeHub with a server-side database. You can configure it according to your actual situation and then choose a deployment platform that suits you to start deployment:
156
156
 
157
- <PlatformCards urlPrefix={'server-database'} />
157
+ <PlatformCards urlPrefix={'platform'} />