@lobehub/chat 1.8.1 → 1.9.0

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 (53) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/Dockerfile +54 -7
  3. package/docs/self-hosting/advanced/auth/clerk.mdx +81 -0
  4. package/docs/self-hosting/advanced/auth/clerk.zh-CN.mdx +71 -0
  5. package/docs/self-hosting/advanced/{sso-providers → auth/next-auth}/auth0.zh-CN.mdx +2 -1
  6. package/docs/self-hosting/advanced/s3/cloudflare-r2.mdx +146 -0
  7. package/docs/self-hosting/advanced/s3/cloudflare-r2.zh-CN.mdx +146 -0
  8. package/docs/self-hosting/advanced/s3.mdx +28 -0
  9. package/docs/self-hosting/advanced/s3.zh-CN.mdx +27 -0
  10. package/docs/self-hosting/advanced/webrtc.mdx +12 -0
  11. package/docs/self-hosting/environment-variables/basic.mdx +13 -0
  12. package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +12 -0
  13. package/docs/self-hosting/server-database/docker-compose.mdx +29 -0
  14. package/docs/self-hosting/server-database/docker-compose.zh-CN.mdx +30 -0
  15. package/docs/self-hosting/server-database/docker.mdx +131 -0
  16. package/docs/self-hosting/server-database/docker.zh-CN.mdx +129 -0
  17. package/docs/self-hosting/server-database/netlify.mdx +14 -0
  18. package/docs/self-hosting/server-database/netlify.zh-CN.mdx +16 -0
  19. package/docs/self-hosting/server-database/railway.mdx +14 -0
  20. package/docs/self-hosting/server-database/railway.zh-CN.mdx +15 -0
  21. package/docs/self-hosting/server-database/repocloud.mdx +16 -0
  22. package/docs/self-hosting/server-database/repocloud.zh-CN.mdx +14 -0
  23. package/docs/self-hosting/server-database/sealos.mdx +12 -0
  24. package/docs/self-hosting/server-database/sealos.zh-CN.mdx +14 -0
  25. package/docs/self-hosting/server-database/vercel.mdx +418 -0
  26. package/docs/self-hosting/{advanced/server-database.zh-CN.mdx → server-database/vercel.zh-CN.mdx} +14 -24
  27. package/docs/self-hosting/server-database/zeabur.mdx +16 -0
  28. package/docs/self-hosting/server-database/zeabur.zh-CN.mdx +14 -0
  29. package/docs/self-hosting/server-database.mdx +164 -0
  30. package/docs/self-hosting/server-database.zh-CN.mdx +169 -0
  31. package/docs/self-hosting/start.mdx +18 -14
  32. package/docs/self-hosting/start.zh-CN.mdx +21 -16
  33. package/docs/usage/providers/novita.mdx +3 -3
  34. package/docs/usage/providers/novita.zh-CN.mdx +3 -1
  35. package/package.json +2 -2
  36. package/src/layout/GlobalProvider/StoreInitialization.tsx +2 -0
  37. package/src/server/globalConfig/index.ts +2 -0
  38. package/src/store/serverConfig/selectors.ts +1 -0
  39. package/src/store/user/slices/auth/action.ts +6 -0
  40. package/src/store/user/slices/auth/initialState.ts +2 -1
  41. package/src/types/serverConfig.ts +1 -0
  42. package/docs/self-hosting/advanced/server-database.mdx +0 -425
  43. /package/docs/self-hosting/advanced/{sso-providers → auth/next-auth}/auth0.mdx +0 -0
  44. /package/docs/self-hosting/advanced/{sso-providers → auth/next-auth}/authentik.mdx +0 -0
  45. /package/docs/self-hosting/advanced/{sso-providers → auth/next-auth}/authentik.zh-CN.mdx +0 -0
  46. /package/docs/self-hosting/advanced/{sso-providers → auth/next-auth}/github.mdx +0 -0
  47. /package/docs/self-hosting/advanced/{sso-providers → auth/next-auth}/github.zh-CN.mdx +0 -0
  48. /package/docs/self-hosting/advanced/{sso-providers → auth/next-auth}/microsoft-entra-id.mdx +0 -0
  49. /package/docs/self-hosting/advanced/{sso-providers → auth/next-auth}/microsoft-entra-id.zh-CN.mdx +0 -0
  50. /package/docs/self-hosting/advanced/{sso-providers → auth/next-auth}/zitadel.mdx +0 -0
  51. /package/docs/self-hosting/advanced/{sso-providers → auth/next-auth}/zitadel.zh-CN.mdx +0 -0
  52. /package/docs/self-hosting/advanced/{authentication.mdx → auth.mdx} +0 -0
  53. /package/docs/self-hosting/advanced/{authentication.zh-CN.mdx → auth.zh-CN.mdx} +0 -0
@@ -0,0 +1,418 @@
1
+ ---
2
+ title: Deploy LobeChat with database on Vercel
3
+ description: >-
4
+ Learn how to deploy LobeChat with database on Vercel with ease, including:
5
+ database, authentication and S3 storage service.
6
+ tags:
7
+ - Deploy LobeChat
8
+ - Vercel Deployment
9
+ - OpenAI API Key
10
+ - Custom Domain Binding
11
+ ---
12
+
13
+ # Deploying Server Database Version on Vercel
14
+
15
+ This article will detail how to deploy the server database version of LobeChat on Vercel, including: 1) database configuration; 2) identity authentication service configuration; 3) steps for setting up the S3 storage service.
16
+
17
+ <Callout type={'warning'}>
18
+ Before proceeding, please make sure of the following:
19
+
20
+ - Export all data, as after deploying the server-side database, existing user data cannot be automatically migrated and can only be manually imported after backup!
21
+ - The `ACCESS_CODE` in the environment variables is either unset or cleared!
22
+ - When configuring the environment variables required for the server-side database, make sure to fill in all of them before deployment, otherwise you may encounter database migration issues!
23
+
24
+ </Callout>
25
+
26
+ ## 1. Configure the Database
27
+
28
+ <Steps>
29
+
30
+ ### Prepare the Server Database Instance and Obtain the Connection URL
31
+
32
+ Before deployment, make sure you have prepared a Postgres database instance. You can choose one of the following methods:
33
+
34
+ - `A.` Use Serverless Postgres instances like Vercel / Neon;
35
+ - `B.` Use self-deployed Postgres instances like Docker.
36
+
37
+ The configuration for both methods is slightly different, and will be distinguished in the next step.
38
+
39
+ ### Add Environment Variables in Vercel
40
+
41
+ In Vercel's deployment environment variables, add `DATABASE_URL` and other environment variables, and fill in the Postgres database connection URL prepared in the previous step. The typical format for the database connection URL is `postgres://username:password@host:port/database`.
42
+
43
+ <Tabs items={['Serverless Postgres', 'Node Postgres']}>
44
+
45
+ <Tab>
46
+
47
+ <Callout type={'warning'}>
48
+ Please confirm the `Postgres` type provided by your vendor. If it is `Node Postgres`, switch to the `Node Postgres` Tab.
49
+ </Callout>
50
+
51
+ Variables to be filled for Serverless Postgres are as follows:
52
+
53
+ ```shell
54
+ # Serverless Postgres DB Url
55
+ DATABASE_URL=
56
+
57
+ # Specify service mode as server, otherwise it will not enter the server-side database
58
+ NEXT_PUBLIC_SERVICE_MODE=server
59
+ ```
60
+
61
+ An example of filling in Vercel is as follows:
62
+
63
+ <Image alt={'Add Serverless Postgres DATABASE_URL'} src={'https://github.com/lobehub/lobe-chat/assets/28616219/d4a710cd-6404-4196-90d0-cd08ca385074'}></Image>
64
+
65
+ </Tab>
66
+
67
+ <Tab>
68
+ Variables to be filled for Node Postgres are as follows:
69
+
70
+ ```shell
71
+ # Node Postgres DB Url
72
+ DATABASE_URL=
73
+
74
+ # Specify Postgres database driver as node
75
+ DATABASE_DRIVER=node
76
+
77
+ # Specify service mode as server, otherwise it will not enter the server-side database
78
+ NEXT_PUBLIC_SERVICE_MODE=server
79
+ ```
80
+
81
+ An example of filling in Vercel is as follows:
82
+
83
+ <Image alt={'Add Node Postgres DATABASE_URL'} src={'https://github.com/lobehub/lobe-chat/assets/28616219/1c689738-809b-4199-b305-ba5770d39da7'}></Image>
84
+
85
+ </Tab>
86
+
87
+ </Tabs>
88
+
89
+ <Callout type={'info'}>
90
+ If you wish to enable SSL when connecting to the database, please refer to the [link](https://stackoverflow.com/questions/14021998/using-psql-to-connect-to-postgresql-in-ssl-mode) for setup instructions.
91
+ </Callout>
92
+
93
+ ### Add the `KEY_VAULTS_SECRET` Environment Variable
94
+
95
+ After adding the DATABASE\_URL environment variable for the database, you need to add a `KEY_VAULTS_SECRET` environment variable. This variable is used to encrypt sensitive information such as apikeys stored by users. You can generate a random 32-character string as the key using `openssl rand -base64 32`.
96
+
97
+ ```shell
98
+ KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
99
+ ```
100
+
101
+ Make sure to add this to the Vercel environment variables as well.
102
+
103
+ </Steps>
104
+
105
+ ## 2. Configure Authentication Service
106
+
107
+ The server-side database needs to be paired with a user authentication service to function properly. Therefore, the corresponding authentication service needs to be configured.
108
+
109
+ <Steps>
110
+
111
+ ### Prepare Clerk Authentication Service
112
+
113
+ Go to [Clerk](https://clerk.com?utm_source=lobehub\&utm_medium=docs) to register and create an application to obtain the corresponding Public Key and Secret Key.
114
+
115
+ <Callout type={'info'}>
116
+ If you are not familiar with Clerk, you can refer to [Authentication Service-Clerk](/en/docs/self-hosting/advanced/authentication#clerk) for details on using Clerk.
117
+ </Callout>
118
+
119
+ ### Add Public and Private Key Environment Variables in Vercel
120
+
121
+ In Vercel's deployment environment variables, add the `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` and `CLERK_SECRET_KEY` environment variables. You can click on "API Keys" in the menu, then copy the corresponding values and paste them into Vercel's environment variables.
122
+
123
+ <Image
124
+ alt={'Find the corresponding public and private key environment variables in Clerk'}
125
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/89883703-7a1a-4a11-b944-5d804544e57c'}>
126
+
127
+ >
128
+ </Image>
129
+
130
+ The environment variables required for this step are as follows:
131
+
132
+ ```shell
133
+ NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
134
+ CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
135
+ ```
136
+
137
+ Add the above variables to Vercel:
138
+
139
+ <Image
140
+ alt={'Add Clerk public and private key environment variables in Vercel'}
141
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/2bfa13df-6e20-4768-97c0-4dad06c85a2f'}>
142
+
143
+ >
144
+ </Image>
145
+
146
+ ### Create and Configure Webhook in Clerk
147
+
148
+ Since we let Clerk fully handle user authentication and management, we need Clerk to notify our application and store data in the database when there are changes in the user's lifecycle (create, update, delete). We achieve this requirement through the Webhook provided by Clerk.
149
+
150
+ We need to add an endpoint in Clerk's Webhooks to inform Clerk to send notifications to this endpoint when a user's information changes.
151
+
152
+ <Image
153
+ alt={'Add Webhooks endpoint in Clerk'}
154
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/f50f47fb-5e8e-4930-bf4e-8cf6f5b8afb9'}>
155
+
156
+ >
157
+ </Image>
158
+
159
+ Fill in the endpoint with the URL of your Vercel project, such as `https://your-project.vercel.app/api/webhooks/clerk`. Then, subscribe to events by checking the three user events (`user.created`, `user.deleted`, `user.updated`), and click create.
160
+
161
+ <Callout type={'warning'}>The `https://` in the URL is essential to maintain the integrity of the URL.</Callout>
162
+
163
+ <Image
164
+ alt={'Configure URL and user events when adding Clerk Webhooks'}
165
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/0249ea56-ab17-4aa9-a56c-9ebd556c2645'}>
166
+
167
+ >
168
+ </Image>
169
+
170
+ ### Add Webhook Secret to Vercel Environment Variables
171
+
172
+ After creation, you can find the secret of this Webhook in the bottom right corner:
173
+
174
+ <Image
175
+ alt={'View Clerk Webhooks secret'}
176
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/fab4abb2-584b-49de-9340-813382951635'}>
177
+
178
+ >
179
+ </Image>
180
+
181
+ The environment variable corresponding to this secret is `CLERK_WEBHOOK_SECRET`:
182
+
183
+ ```shell
184
+ CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
185
+ ```
186
+
187
+ Add it to Vercel's environment variables:
188
+
189
+ <Image
190
+ alt={'Add Clerk Webhooks secret in Vercel'}
191
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/5fdc9479-007f-46ab-9d6e-a9603e949116'}>
192
+
193
+ >
194
+ </Image>
195
+
196
+ </Steps>
197
+
198
+ By completing these steps, you have successfully configured the Clerk authentication service. Next, we will configure the S3 storage service.
199
+
200
+ ## 3. Configure S3 Storage Service
201
+
202
+ In the server-side database, we need to configure the S3 storage service to store files.
203
+
204
+ <Callout type={'info'}>
205
+ In this article, S3 refers to a compatible S3 storage solution, which supports object storage systems that comply with the Amazon S3 API. Common examples include Cloudflare R2, Alibaba Cloud OSS, etc., all of which support S3-compatible APIs.
206
+ </Callout>
207
+
208
+ <Steps>
209
+
210
+ ### Configure and Obtain S3 Bucket
211
+
212
+ You need to go to your S3 service provider (such as AWS S3, Cloudflare R2, etc.) and create a new storage bucket. The following steps will use Cloudflare R2 as an example to explain the creation process.
213
+
214
+ The interface of Cloudflare R2 is shown below:
215
+
216
+ <Image
217
+ alt={'Cloudflare R2 Storage Interface'}
218
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/41f7f677-0153-4a96-b849-5ac9b7ebefee'}
219
+ ></Image>
220
+
221
+ When creating a storage bucket, specify its name and then click create.
222
+ <Image
223
+ alt={'Create Storage Bucket in R2'}
224
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/9c0d184c-3169-40fa-9115-011cfffb9ca7'}
225
+ ></Image>
226
+
227
+ ### Obtain Environment Variables for the Bucket
228
+
229
+ In the settings of the R2 storage bucket, you can view the bucket configuration information:
230
+
231
+ <Image
232
+ alt={'View Storage Bucket Information'}
233
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/2ceb210c-eca0-4439-ba27-8734d4ebb3ee'}
234
+ ></Image>
235
+
236
+ The corresponding environment variables are:
237
+
238
+ ```shell
239
+ # Storage bucket name
240
+ S3_BUCKET=lobechat
241
+ # Storage bucket request endpoint (note that the path in this link includes the bucket name, which must be removed, or use the link provided on the S3 API token application page)
242
+ S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
243
+ # Public access domain for the storage bucket
244
+ NEXT_PUBLIC_S3_DOMAIN=https://s3-for-lobechat.your-domain.com
245
+ ```
246
+
247
+ <Callout type={'warning'}>`S3_ENDPOINT` must have its path removed, otherwise uploaded files will not be accessible</Callout>
248
+
249
+ ### Obtain S3 Key Environment Variables
250
+
251
+ You need to obtain the access key for S3 so that the LobeChat server has permission to access the S3 storage service. In R2, you can configure the access key in the account details:
252
+
253
+ <Image
254
+ alt={'View Storage Bucket Access Key'}
255
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/be0c95c0-6693-44ee-a490-7e8dfaa8b34d'}
256
+ ></Image>
257
+
258
+ Click the button in the upper right corner to create an API token and enter the create API Token page.
259
+
260
+ <Image
261
+ alt={'Create Corresponding API Token'}
262
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/7b0ea46c-5157-40a8-888f-f47664a4884f'}
263
+ ></Image>
264
+
265
+ Since our server-side database needs to read and write to the S3 storage service, the permission needs to be set to `Object Read and Write`, then click create.
266
+
267
+ <Image
268
+ alt={'Configure API Token Permissions'}
269
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/d6f5a918-7b50-4d6e-83a6-3894ab930ddf'}
270
+ ></Image>
271
+
272
+ After creation, you can see the corresponding S3 API token.
273
+
274
+ <Image
275
+ alt={'Copy API Token'}
276
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/763b18f9-2b5f-44bb-a479-9b56d46f7397'}
277
+ ></Image>
278
+
279
+ The corresponding environment variables are:
280
+
281
+ ```shell
282
+ S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
283
+ S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
284
+ ```
285
+
286
+ ### Adding Corresponding Environment Variables in Vercel
287
+
288
+ The steps to obtain the required environment variables may vary for different S3 service providers, but the obtained environment variables should be consistent:
289
+
290
+ <Callout type={'warning'}>The `https://` in the URL is essential and must be maintained for the completeness of the URL.</Callout>
291
+
292
+ ```shell
293
+ # S3 Keys
294
+ S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
295
+ S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
296
+
297
+ # Bucket name
298
+ S3_BUCKET=lobechat
299
+ # Bucket request endpoint
300
+ S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
301
+ # Public domain for bucket access
302
+ NEXT_PUBLIC_S3_DOMAIN=https://s3-dev.your-domain.com
303
+
304
+ # Bucket region, such as us-west-1, generally not required, but some providers may need to configure
305
+ # S3_REGION=us-west-1
306
+ ```
307
+
308
+ Then, insert the above environment variables into Vercel's environment variables:
309
+
310
+ <Image
311
+ alt={'Adding S3 environment variables in Vercel'}
312
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/cd74152d-0ae8-44fd-b815-3307c56a3c18'}
313
+ ></Image>
314
+
315
+ ### Configuring Cross-Origin Resource Sharing (CORS)
316
+
317
+ Since S3 storage services are often on a separate domain, cross-origin access needs to be configured.
318
+
319
+ In R2, you can find the CORS configuration in the bucket settings:
320
+
321
+ <Image
322
+ alt={'Cloudflare R2 CORS settings'}
323
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/ab008be7-26b2-4b78-8bd9-24301bf34d23'}
324
+ ></Image>
325
+
326
+ Add a CORS rule to allow requests from your domain (in this case, `https://your-project.vercel.app`):
327
+
328
+ <Image
329
+ alt={'Configuring allowed site domain'}
330
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/dfcc2cb3-2958-4498-a8a4-51bec584fe7d'}
331
+ ></Image>
332
+
333
+ Example configuration:
334
+
335
+ ```json
336
+ [
337
+ {
338
+ "AllowedOrigins": ["https://your-project.vercel.app"],
339
+ "AllowedMethods": ["GET", "PUT", "HEAD", "POST", "DELETE"],
340
+ "AllowedHeaders": ["*"]
341
+ }
342
+ ]
343
+ ```
344
+
345
+ After configuring, click save.
346
+
347
+ </Steps>
348
+
349
+ ## Four, Deployment and Verification
350
+
351
+ After completing the steps above, the configuration of the server-side database should be done. Next, we can deploy LobeChat to Vercel and then visit your Vercel link to verify if the server-side database is working correctly.
352
+
353
+ <Steps>
354
+ ### Redeploy the latest commit
355
+
356
+ After configuring the environment variables, you need to redeploy the latest commit and wait for the deployment to complete.
357
+
358
+ <Image
359
+ alt={'Redeploy the latest commit'}
360
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/b3a78112-adc8-4837-b4e3-48f67058f16e'}>
361
+
362
+ >
363
+ </Image>
364
+
365
+ ### Check if the features are working properly
366
+
367
+ If you click on the login button in the top left corner and the login popup appears normally, then you have successfully configured it. Enjoy using it\~
368
+
369
+ <Image
370
+ alt={'User login popup'}
371
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/da84edc3-46f7-4e2b-a0cd-dc33a98bf5cb'}>
372
+
373
+ >
374
+ </Image>
375
+
376
+ <Image
377
+ alt={'Login successful state'}
378
+ src={'https://github.com/lobehub/lobe-chat/assets/28616219/9cb5150d-6e1e-4c59-9a18-4e418dce1a5d'}>
379
+
380
+ >
381
+ </Image>
382
+
383
+ </Steps>
384
+
385
+ ## Appendix
386
+
387
+ ### Overview of Server-side Database Environment Variables
388
+
389
+ For easy copying, here is a summary of the environment variables required to configure the server-side database:
390
+
391
+ ```shell
392
+ # Specify the service mode as server
393
+ NEXT_PUBLIC_SERVICE_MODE=server
394
+
395
+ # Postgres database URL
396
+ DATABASE_URL=
397
+ KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
398
+
399
+ # Clerk related configurations
400
+ NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
401
+ CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
402
+ CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
403
+
404
+ # S3 related configurations
405
+ # S3 keys
406
+ S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
407
+ S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
408
+
409
+ # Bucket name
410
+ S3_BUCKET=lobechat
411
+ # Bucket request endpoint
412
+ S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
413
+ # Public access domain for the bucket
414
+ NEXT_PUBLIC_S3_DOMAIN=https://s3-for-lobechat.your-domain.com
415
+ # Bucket region, such as us-west-1, generally not needed to add, but some service providers may require configuration
416
+ # S3_REGION=us-west-1
417
+ ```
418
+
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: 使用服务端数据库部署 - 配置 Postgres、Clerk 和 S3 存储服务
2
+ title: Vercel 上部署 LobeChat 的服务端数据库版本
3
3
  description: 本文详细介绍如何在 Vercel 中部署服务端数据库版 LobeChat,包括数据库配置、身份验证服务配置和 S3 存储服务的设置步骤。
4
4
  tags:
5
5
  - 服务端数据库
@@ -12,20 +12,14 @@ tags:
12
12
  - 环境变量配置
13
13
  ---
14
14
 
15
- # 使用服务端数据库部署
16
-
17
- LobeChat 默认使用客户端数据库(IndexedDB),同时也支持使用服务端数据库。LobeChat 采用了 Postgres 作为后端存储数据库。PostgreSQL是一种强大的开源关系型数据库管理系统,具备高度扩展性和标准SQL支持。它提供了丰富的数据类型、并发处理、数据完整性、安全性及可编程性,适用于复杂应用和大规模数据管理。
15
+ # 在 Vercel 上部署服务端数据库版
18
16
 
19
17
  本文将详细介绍如何在 Vercel 中部署服务端数据库版 LobeChat,包括: 1)数据库配置;2)身份验证服务配置;3) S3 存储服务的设置步骤。
20
18
 
21
- <Callout type={'info'}>
22
- 限于工作量原因,目前仅支持在 Vercel 中部署使用服务端数据库版本,Docker 版本将会在后续迭代中支持。
23
- </Callout>
24
-
25
19
  <Callout type={'warning'}>
26
- 进行后续操作前,请务必确认以下事项
27
- - 导出所有数据,部署服务端数据库后,原有用户数据无法自动迁移,只能提前备份后进行手动导入!
28
- - 环境变量中的`ACCESS_CODE`未设置或已清除!
20
+ 进行后续操作前,请务必确认以下事项:
21
+ - 导出所有数据,部署服务端数据库后,原有用户数据无法自动迁移,只能提前备份后进行手动导入!
22
+ - 环境变量中的`ACCESS_CODE`未设置或已清除!
29
23
  - 配置服务端数据库所需要的环境变量时,需全部填入后再进行部署,否则可能遭遇数据库迁移问题!
30
24
  </Callout>
31
25
 
@@ -46,14 +40,15 @@ LobeChat 默认使用客户端数据库(IndexedDB),同时也支持使用
46
40
 
47
41
  在 Vercel 的部署环境变量中,添加 `DATABASE_URL` 等环境变量,将上一步准备好的 Postgres 数据库连接 URL 填入其中。数据库连接 URL 的通常格式为 `postgres://username:password@host:port/database`。
48
42
 
49
- <Callout type={'warning'}>
50
- 确认您的供应商所提供的`Postgres`类型,若为`Node Postgres`,则必须添加环境变量`DATABASE_DRIVER=node`
51
- </Callout>
52
-
53
43
  <Tabs items={['Serverless Postgres', 'Node Postgres']}>
54
44
 
55
45
  <Tab>
56
46
 
47
+ <Callout type={'warning'}>
48
+ 请确认您的供应商所提供的 `Postgres` 类型,若为 `Node Postgres`,请切换到 `Node Postgres` Tab 。
49
+
50
+ </Callout>
51
+
57
52
  Serverless Postgres 需要填写的变量如下:
58
53
 
59
54
  ```shell
@@ -93,7 +88,8 @@ LobeChat 默认使用客户端数据库(IndexedDB),同时也支持使用
93
88
  </Tabs>
94
89
 
95
90
  <Callout type={'info'}>
96
- 如果希望连接数据库时启用 SSL ,请自行参考[链接](https://stackoverflow.com/questions/14021998/using-psql-to-connect-to-postgresql-in-ssl-mode)进行设置
91
+ 如果希望连接数据库时启用 SSL
92
+ ,请自行参考[链接](https://stackoverflow.com/questions/14021998/using-psql-to-connect-to-postgresql-in-ssl-mode)进行设置
97
93
  </Callout>
98
94
 
99
95
  ### 添加 `KEY_VAULTS_SECRET` 环境变量
@@ -112,10 +108,6 @@ KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
112
108
 
113
109
  服务端数据库需要搭配用户身份验证服务才可以正常使用。因此需要配置对应的身份验证服务。
114
110
 
115
- <Callout type={'warning'}>
116
- 同样由于工作量原因,目前仅支持 Clerk 作为身份验证服务方案, Next-Auth 的服务端数据库集成有待开发
117
- </Callout>
118
-
119
111
  <Steps>
120
112
 
121
113
  ### 准备 Clerk 身份验证服务
@@ -198,7 +190,7 @@ CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
198
190
 
199
191
  ## 三、 配置 S3 存储服务
200
192
 
201
- LobeChat 在很早以前就支持了多模态 的 AI 会话,其中涉及到图片上传给 AI 的功能。在客户端数据库方案中,图片文件直接以二进制数据存储在浏览器 indexedDB 数据库,但在服务端数据库中这个方案并不可行。我们需要配置 S3 存储服务来存储大量的图片文件,同时 S3 也可以作为文件上传的存储方案。
193
+ 在服务端数据库中我们需要配置 S3 存储服务来存储文件。
202
194
 
203
195
  <Callout type={'info'}>
204
196
  在本文,S3所指代的是指兼容 S3 存储方案,即支持 Amazon S3 API 的对象存储系统,常见例如 Cloudflare
@@ -262,9 +254,7 @@ NEXT_PUBLIC_S3_DOMAIN=https://s3-for-lobechat.your-domain.com
262
254
  src={'https://github.com/lobehub/lobe-chat/assets/28616219/7b0ea46c-5157-40a8-888f-f47664a4884f'}
263
255
  ></Image>
264
256
 
265
- 鉴于我们的服务端数据库需要读写 S3 存储服务,因此权限需要选择`管理员读与写`,然后点击创建。
266
-
267
- <Callout type={'warning'}>权限必须为`管理员读与写`,否则无法上传照片等其它文件</Callout>
257
+ 鉴于我们的服务端数据库需要读写 S3 存储服务,因此权限需要选择`对象读与写`,然后点击创建。
268
258
 
269
259
  <Image
270
260
  alt={'配置 API token 权限'}
@@ -0,0 +1,16 @@
1
+ ---
2
+ title: Deploying LobeChat Database on Zeabur
3
+ description: >-
4
+ Learn how to deploy LobeChat on Zeabur with ease. Follow the provided steps to
5
+ set up your chat application seamlessly.
6
+ tags:
7
+ - Deploy LobeChat
8
+ - Zeabur Deployment
9
+ - OpenAI API Key
10
+ - Custom Domain Binding
11
+ ---
12
+
13
+ # Deploying LobeChat Database on Zeabur
14
+
15
+ TODO
16
+
@@ -0,0 +1,14 @@
1
+ ---
2
+ title: 在 Zeabur 上部署 LobeChat
3
+ description: 按照指南准备 OpenAI API Key 并点击按钮进行部署。在部署完成后,即可开始使用 LobeChat 并选择是否绑定自定义域名。
4
+ tags:
5
+ - Zeabur
6
+ - LobeChat
7
+ - OpenAI API Key
8
+ - 部署流程
9
+ - 自定义域名
10
+ ---
11
+
12
+ # 使用 Zeabur 部署 LobeChat 数据库版
13
+
14
+ TODO