@lobehub/chat 1.14.2 → 1.14.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.
- package/CHANGELOG.md +50 -0
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/docker-compose/.env.example +35 -0
- package/docker-compose/.env.zh-CN.example +35 -0
- package/docker-compose/docker-compose.yml +70 -0
- package/docker-compose/minio-bucket.config.json +34 -0
- package/docs/self-hosting/advanced/auth/next-auth/github.mdx +1 -1
- package/docs/self-hosting/advanced/auth/next-auth/github.zh-CN.mdx +4 -4
- package/docs/self-hosting/advanced/auth/next-auth/logto.mdx +74 -0
- package/docs/self-hosting/advanced/auth/next-auth/logto.zh-CN.mdx +78 -0
- package/docs/self-hosting/environment-variables/auth.mdx +21 -0
- package/docs/self-hosting/environment-variables/auth.zh-CN.mdx +31 -8
- package/docs/self-hosting/server-database/docker-compose.mdx +486 -7
- package/docs/self-hosting/server-database/docker-compose.zh-CN.mdx +477 -4
- package/docs/self-hosting/server-database/docker.mdx +20 -0
- package/docs/self-hosting/server-database/docker.zh-CN.mdx +27 -4
- package/docs/usage/features/pwa.zh-CN.mdx +1 -1
- package/package.json +2 -2
- package/src/app/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/Tags.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/features/ShareButton/Preview.tsx +1 -1
- package/src/app/(main)/chat/@session/features/SessionListContent/List/Item/index.tsx +1 -1
- package/src/app/(main)/settings/llm/ProviderList/Azure/index.tsx +1 -14
- package/src/app/(main)/settings/llm/ProviderList/Bedrock/index.tsx +1 -10
- package/src/app/(main)/settings/llm/ProviderList/Ollama/index.tsx +0 -2
- package/src/app/(main)/settings/llm/ProviderList/OpenAI/index.tsx +0 -3
- package/src/app/(main)/settings/llm/ProviderList/providers.tsx +28 -174
- package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +17 -17
- package/src/app/(main)/settings/llm/components/ProviderModelList/CustomModelOption.tsx +1 -1
- package/src/app/(main)/settings/llm/components/ProviderModelList/Option.tsx +1 -1
- package/src/app/(main)/settings/tts/features/{const.ts → const.tsx} +6 -3
- package/src/components/ModelSelect/index.tsx +15 -5
- package/src/const/url.ts +1 -0
- package/src/database/server/models/asyncTask.ts +4 -4
- package/src/features/AgentSetting/AgentTTS/options.tsx +19 -0
- package/src/features/Conversation/Extras/Assistant.tsx +1 -1
- package/src/server/routers/async/caller.ts +2 -0
- package/src/server/routers/async/file.ts +72 -46
- package/src/server/services/chunk/index.ts +32 -3
- package/src/types/asyncTask.ts +23 -4
- package/src/components/ModelIcon/index.tsx +0 -114
- package/src/components/ModelProviderIcon/index.tsx +0 -148
- package/src/components/ModelTag/ModelIcon.tsx +0 -105
- package/src/components/ModelTag/index.tsx +0 -13
- package/src/features/AgentSetting/AgentTTS/options.ts +0 -16
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: 通过 Docker Compose 部署 LobeChat
|
|
3
|
-
description: 学习如何使用 Docker Compose 部署 LobeChat
|
|
3
|
+
description: 学习如何使用 Docker Compose 部署 LobeChat 服务,包括各种服务的配置教程。
|
|
4
4
|
tags:
|
|
5
5
|
- Docker Compose
|
|
6
6
|
- LobeChat
|
|
7
7
|
- Docker 容器
|
|
8
|
-
- 自动更新脚本
|
|
9
8
|
- 部署指引
|
|
10
9
|
---
|
|
11
10
|
|
|
12
|
-
# 使用 Docker Compose
|
|
11
|
+
# 使用 Docker Compose 部署 LobeChat 服务端数据库版本
|
|
13
12
|
|
|
14
13
|
<div style={{display:"flex", gap: 4}}>
|
|
15
14
|
[![][docker-release-shield]][docker-release-link]
|
|
@@ -20,7 +19,481 @@ tags:
|
|
|
20
19
|
|
|
21
20
|
</div>
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
<Callout type="info">
|
|
23
|
+
本文已经假定你了解了 LobeChat 服务端数据库版本(下简称 DB
|
|
24
|
+
版)的部署基本原理和流程,因此只包含核心环境变量配置的内容。如果你还不了解 LobeChat DB
|
|
25
|
+
版的部署原理,请先查阅 [使用服务端数据库部署](/zh/docs/self-hosting/server-database) 。
|
|
26
|
+
</Callout>
|
|
27
|
+
|
|
28
|
+
<Callout type="warning">
|
|
29
|
+
由于无法使用 Docker 环境变量暴露 `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY`,使用 Docker / Docker Compose
|
|
30
|
+
部署 LobeChat 时,你不能使用 Clerk 作为登录鉴权服务。
|
|
31
|
+
|
|
32
|
+
如果你确实需要 Clerk 作为登录鉴权服务,你可以考虑使用 Vercel 部署或者自行构建镜像。
|
|
33
|
+
|
|
34
|
+
</Callout>
|
|
35
|
+
|
|
36
|
+
## 快速启动
|
|
37
|
+
|
|
38
|
+
以下假设你选择自建 LobeChat 全部四个所需服务,即:
|
|
39
|
+
|
|
40
|
+
- LobeChat 数据库版本自身
|
|
41
|
+
- PostgreSQL:带有 PGVector 插件
|
|
42
|
+
- Logto:SSO 登录鉴权服务
|
|
43
|
+
- MinIO:支持 S3 协议的本地对象存储服务
|
|
44
|
+
|
|
45
|
+
<Steps>
|
|
46
|
+
### 创建配置文件
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
curl -fsSL https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/docker-compose.yml
|
|
50
|
+
curl -fsSL https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/.env.zh-CN.example > .env
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
你也可以从下文的附录中复制得到这两份示例配置文件。
|
|
54
|
+
|
|
55
|
+
请按照注释,修改你的 `.env` 和 `docker-compose.yml` 文件。
|
|
56
|
+
|
|
57
|
+
### 启动服务
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
docker compose up -d
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 配置 Logto
|
|
64
|
+
|
|
65
|
+
1. 打开 `http://localhost:3002`,访问 Logto WebUI,注册管理员账号
|
|
66
|
+
|
|
67
|
+
2. 创建一个 `Next.js (App Router)` 应用,添加以下配置:
|
|
68
|
+
|
|
69
|
+
- `Redirect URI` 为 `http://localhost:3210/api/auth/callback/logto`
|
|
70
|
+
- `Post sign-out redirect URI` 为 `http://localhost:3210/`
|
|
71
|
+
- `CORS allowed origins` 为 `http://localhost:3210`
|
|
72
|
+
|
|
73
|
+
3. 获取 `Client ID` 和 `Client Secret`,填入你的 `.env` 文件中对应的 `LOGTO_CLIENT_ID` 、 `LOGTO_CLIENT_SECRETT`
|
|
74
|
+
|
|
75
|
+
4. 配置你的 `.env` 文件中的 `LOGTO_ISSUER` 为 `http://localhost:3001/oidc`
|
|
76
|
+
|
|
77
|
+
### 配置 MinIO S3
|
|
78
|
+
|
|
79
|
+
1. 打开 `http://localhost:9001`,访问 MinIO WebUI,默认管理员账号密码在 `docker-compose.yml` 中配置
|
|
80
|
+
|
|
81
|
+
2. 创建符合你的 `.env` 文件中 `S3_BUCKET` 字段的桶,默认为 `lobe`
|
|
82
|
+
|
|
83
|
+
3. 选择自定义策略,复制如下内容,粘贴之(如果你修改了桶名,请自行查找替换)
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"Statement": [
|
|
88
|
+
{
|
|
89
|
+
"Effect": "Allow",
|
|
90
|
+
"Principal": {
|
|
91
|
+
"AWS": ["*"]
|
|
92
|
+
},
|
|
93
|
+
"Action": ["s3:GetBucketLocation"],
|
|
94
|
+
"Resource": ["arn:aws:s3:::lobe"]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"Effect": "Allow",
|
|
98
|
+
"Principal": {
|
|
99
|
+
"AWS": ["*"]
|
|
100
|
+
},
|
|
101
|
+
"Action": ["s3:ListBucket"],
|
|
102
|
+
"Resource": ["arn:aws:s3:::lobe"],
|
|
103
|
+
"Condition": {
|
|
104
|
+
"StringEquals": {
|
|
105
|
+
"s3:prefix": ["files/*"]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"Effect": "Allow",
|
|
111
|
+
"Principal": {
|
|
112
|
+
"AWS": ["*"]
|
|
113
|
+
},
|
|
114
|
+
"Action": ["s3:PutObject", "s3:DeleteObject", "s3:GetObject"],
|
|
115
|
+
"Resource": ["arn:aws:s3:::lobe/files/**"]
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"Version": "2012-10-17"
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
4. 创建一个新的访问密钥,将生成的 `Access Key` 和 `Secret Key` 填入你的 `.env` 文件中的 `S3_ACCESS_KEY_ID` 和 `S3_SECRET_ACCESS_KEY` 中
|
|
123
|
+
|
|
124
|
+
### 重启 LobeChat 服务
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
docker compose up -d
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
<Callout typr="warning">
|
|
131
|
+
此时,请勿使用 `docker compose restart lobe` 来重启,因为这种重启方式不会重新加载环境变量,你的
|
|
132
|
+
S3 配置将不会生效。
|
|
133
|
+
|
|
134
|
+
</Callout>
|
|
135
|
+
</Steps>
|
|
136
|
+
|
|
137
|
+
至此,你已经成功部署了 LobeChat 数据库版本,你可以通过 `http://localhost:3210` 访问你的 LobeChat 服务。
|
|
138
|
+
|
|
139
|
+
如果你遇到问题,请尝试查看 Docker 日志和控制台日志,并根据后文的详细指引进行排查。
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
docker logs -f lobe-database
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
如果你在容器中看到了以下日志,则说明已经启动成功:
|
|
146
|
+
|
|
147
|
+
```log
|
|
148
|
+
[Database] Start to migration...
|
|
149
|
+
✅ database migration pass.
|
|
150
|
+
-------------------------------------
|
|
151
|
+
▲ Next.js 14.x.x
|
|
152
|
+
- Local: http://localhost:3210
|
|
153
|
+
- Network: http://0.0.0.0:3210
|
|
154
|
+
|
|
155
|
+
✓ Starting...
|
|
156
|
+
✓ Ready in 95ms
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## 发布到生产
|
|
160
|
+
|
|
161
|
+
一般来讲,想要完整的运行 LobeChat 数据库版本,你需要至少拥有如下四个服务
|
|
162
|
+
|
|
163
|
+
- LobeChat 数据库版本自身
|
|
164
|
+
- 带有 PGVector 插件的 PostgreSQL 数据库
|
|
165
|
+
- 支持 S3 协议的对象存储服务
|
|
166
|
+
- 受 LobeChat 支持的 SSO 登录鉴权服务
|
|
167
|
+
|
|
168
|
+
这些服务可以通过自建或者在线云服务组合搭配,以满足你的需求。
|
|
169
|
+
|
|
170
|
+
我们提供了一份完全基于自建的 Docker Compose 配置,你可以直接使用这份配置文件来启动 LobeChat 数据库版本,也可以对之进行修改以适应你的需求。
|
|
171
|
+
|
|
172
|
+
我们默认使用 [MinIO](https://github.com/minio/minio) 作为本地 S3 对象存储服务,使用 [Logto](https://github.com/logto-io/logto) 作为本地鉴权服务。
|
|
173
|
+
|
|
174
|
+
我们同时假设在这些服务之外,你还运行了一层 Nginx 来进行反向代理、配置 SSL。
|
|
175
|
+
|
|
176
|
+
域名和配套服务端口说明如下:
|
|
177
|
+
|
|
178
|
+
- `lobe.example.com`:为你的 LobeChat 服务端域名,需要反向代理到 LobeChat 服务端口,默认为 `3210`
|
|
179
|
+
- `lobe-auth-api.example.com`:为你的 Logto 服务端域名,需要反向代理到 Logto API 服务端口,默认为 `3001`
|
|
180
|
+
- `lobe-auth-ui.example.com`:为你的 Logto UI 域名,需要反向代理到 Logto WebUI 服务端口,默认为 `3002`
|
|
181
|
+
- `lobe-s3-api.example.com`:为你的 MinIO API 域名,需要反向代理到 MinIO API 服务端口,默认为 `9000`
|
|
182
|
+
- `lobe-s3-ui.example.com`:可选,为你的 MinIO UI 域名,需要反向代理到 MinIO WebUI 服务端口,默认为 `9001`
|
|
183
|
+
|
|
184
|
+
以及不进行反向代理的服务端口:
|
|
185
|
+
|
|
186
|
+
- `postgresql`:你的 PostgreSQL 数据库服务端口,默认为 `5432`
|
|
187
|
+
|
|
188
|
+
<Callout type="warning">
|
|
189
|
+
请务必注意,CORS 跨域是在 MinIO / Logto 服务端内部配置的,请勿在你的反向代理中额外配置 CORS,这会导致错误。
|
|
190
|
+
|
|
191
|
+
如果你需要配置 SSL 证书,请统一在外层的 Nginx 反向代理中配置,而不是在 MinIO 中配置。
|
|
192
|
+
|
|
193
|
+
</Callout>
|
|
194
|
+
|
|
195
|
+
### 配置文件
|
|
196
|
+
|
|
197
|
+
配置文件包括 `.env` 和 `docker-compose.yml` 两个文件,其中 `.env` 文件用于配置 LobeChat 的环境变量,`docker-compose.yml` 文件用于配置 Postgres、MinIO 和 Logto 服务。
|
|
198
|
+
|
|
199
|
+
一般情况下,你只应修改其中的域名和账号密码等敏感信息,其他配置项请按照默认值进行配置。
|
|
200
|
+
|
|
201
|
+
它们的示例配置请参见本文附录。
|
|
202
|
+
|
|
203
|
+
### Postgres 数据库配置
|
|
204
|
+
|
|
205
|
+
<Callout type="warning">
|
|
206
|
+
请注意,首次运行 `docker compose up -d` 时,可能会因为 Postgres 数据库尚未初始化完毕,而 LobeChat
|
|
207
|
+
已经尝试连接而失败,出现 `Database migrate failed` 错误并退出。此时,你需要输入 `docker compose
|
|
208
|
+
restart lobe` 来重启 LobeChat,从而使其连接到正确的数据库。
|
|
209
|
+
</Callout>
|
|
210
|
+
|
|
211
|
+
你可以使用下述指令检查日志:
|
|
212
|
+
|
|
213
|
+
```sh
|
|
214
|
+
docker logs -f lobe-database
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
<Callout type="tip">
|
|
218
|
+
在我们官方的 Docker 镜像中,会在启动镜像前自动执行数据库 schema 的 migration
|
|
219
|
+
,我们的官方镜像承诺「空数据库 ->
|
|
220
|
+
完整表」这一段自动建表的稳定性。因此我们建议你的数据库实例使用一个空表实例,进而省去手动维护表结构或者
|
|
221
|
+
migration 的麻烦。
|
|
222
|
+
</Callout>
|
|
223
|
+
|
|
224
|
+
如果你在建表的时候出现了问题,你可以尝试使用如下命令强制移除数据库容器并重新启动:
|
|
225
|
+
|
|
226
|
+
```sh
|
|
227
|
+
docker compose down # 停止服务
|
|
228
|
+
sudo rm -rf ./data # 移除挂载的数据库数据
|
|
229
|
+
docker compose up -d # 重新启动
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### 登录鉴权服务配置
|
|
233
|
+
|
|
234
|
+
本文以 Logto 为例,解释配置过程,如果你使用的是其他登录鉴权服务商,请参照其文档进行配置。
|
|
235
|
+
|
|
236
|
+
<Callout type="warning">
|
|
237
|
+
请记得注意配置对应登录鉴权服务提供商的 CORS 跨域配置,以确保 LobeChat 能够正常访问登录鉴权服务。
|
|
238
|
+
|
|
239
|
+
在本文中,你需要允许 `https://lobe.example.com` 的跨域请求。
|
|
240
|
+
|
|
241
|
+
</Callout>
|
|
242
|
+
|
|
243
|
+
你需要首先访问 WebUI 来进行配置:
|
|
244
|
+
|
|
245
|
+
- 如果你按照前文配置了反向代理,打开 `https://lobe-auth-ui.example.com`
|
|
246
|
+
- 否则,请在进行端口映射后,打开 `http://localhost:3002`
|
|
247
|
+
|
|
248
|
+
1. 注册一个新账户,首个注册的账户将自动成为管理员
|
|
249
|
+
|
|
250
|
+
2. 在 `Applications` 里创建一个 `Next.js (App Router)` 应用,名称随意
|
|
251
|
+
|
|
252
|
+
3. 配置 `Redirect URI` 为 `https://lobe.example.com/api/auth/callback/logto`,`Post sign-out redirect URI` 为 `https://lobe.example.com/`
|
|
253
|
+
|
|
254
|
+
4. 配置 `CORS allowed origins` 为 `https://lobe.example.com`
|
|
255
|
+
|
|
256
|
+
<Image
|
|
257
|
+
alt="配置 Logto"
|
|
258
|
+
src="https://github.com/user-attachments/assets/5b816379-c07b-40ea-bde4-df16e2e4e523"
|
|
259
|
+
/>
|
|
260
|
+
|
|
261
|
+
5. 获取 `Client ID` 和 `Client Secret`,填入你的 `.env` 文件中的 `LOGTO_CLIENT_ID` 和 `LOGTO_CLIENT_SECRETT` 中
|
|
262
|
+
|
|
263
|
+
6. 配置你的 `.env` 文件中 `LOGTO_ISSUER` 为 `https://lobe-auth-api.example.com/oidc`
|
|
264
|
+
|
|
265
|
+
<Image
|
|
266
|
+
alt="配置 Logto 环境变量"
|
|
267
|
+
src="https://github.com/user-attachments/assets/15af6d94-af4f-4aa9-bbab-7a46e9f9e837"
|
|
268
|
+
/>
|
|
269
|
+
|
|
270
|
+
7. 可选,在左侧 `Sign-in experience` 面板的 `Sign-up and sign-in - Advanced Options` 中关闭 `Enable user registration`,禁止用户自行注册。如果你禁止了用户自行注册,那么你只能在左侧 `User Management` 里手动添加用户。
|
|
271
|
+
|
|
272
|
+
<Image
|
|
273
|
+
alt="关闭用户注册"
|
|
274
|
+
src="https://github.com/user-attachments/assets/6b2e6f7b-fec5-41c6-864a-a1add40f74a0"
|
|
275
|
+
/>
|
|
276
|
+
|
|
277
|
+
8. 重启 LobeChat 服务:
|
|
278
|
+
|
|
279
|
+
```sh
|
|
280
|
+
docker compose up -d
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
<Callout type="warning">
|
|
284
|
+
请注意,管理员账户不等同于注册用户,不要用你的管理员账户登录 LobeChat,那样只会报错。
|
|
285
|
+
</Callout>
|
|
286
|
+
|
|
287
|
+
### S3 对象存储服务配置
|
|
288
|
+
|
|
289
|
+
本文以 MinIO 为例,解释配置过程,如果你使用的是其他 S3 服务商,请参照其文档进行配置。
|
|
290
|
+
|
|
291
|
+
<Callout type="warning">
|
|
292
|
+
请记得注意配置对应 S3 服务商的 CORS 跨域配置,以确保 LobeChat 能够正常访问 S3 服务。
|
|
293
|
+
|
|
294
|
+
在本文中,你需要允许 `https://lobe.example.com` 的跨域请求。这既可以在 MinIO WebUI 的 `Configuration - API - Cors Allow Origin` 中配置,也可以在 Docker Compose 中的 `minio - environment - MINIO_API_CORS_ALLOW_ORIGIN` 中配置。
|
|
295
|
+
|
|
296
|
+
如果你使用第二种方法(这也是默认的方法)进行配置,你将无法再在 MinIO WebUI 中配置。
|
|
297
|
+
|
|
298
|
+
</Callout>
|
|
299
|
+
|
|
300
|
+
你需要首先访问 WebUI 来进行配置:
|
|
301
|
+
|
|
302
|
+
- 如果你按照前文配置了反向代理,打开 `https://lobe-s3-api.example.com`
|
|
303
|
+
- 否则,请在进行端口映射后,打开 `http://localhost:9001`
|
|
304
|
+
|
|
305
|
+
1. 在登录界面输入你设置的 `MINIO_ROOT_USER` 和 `MINIO_ROOT_PASSWORD`,然后点击登录
|
|
306
|
+
|
|
307
|
+
2. 在左侧面板 Administer / Buckets 中点击 `Create Bucket`,输入 `lobe`(对应你的 `S3_BUCKET` 环境变量),然后点击 `Create`
|
|
308
|
+
|
|
309
|
+
<Image
|
|
310
|
+
alt="创建 MinIO 桶"
|
|
311
|
+
src="https://github.com/user-attachments/assets/79f44a13-00d3-4302-a6bc-5f4c6cdbffab"
|
|
312
|
+
/>
|
|
313
|
+
|
|
314
|
+
3. 选中你的桶,点击 Summary - Access Policy,编辑,选择 `Custom`,输入 `minio-bucket-config.json` 中的内容(见附录)并保存(同样默认你的桶名为 `lobe`):
|
|
315
|
+
|
|
316
|
+
<Image
|
|
317
|
+
alt="选中 MinIO 桶策略"
|
|
318
|
+
src="https://github.com/user-attachments/assets/57032a82-7604-45d3-ba12-884af6fbcb7c"
|
|
319
|
+
/>
|
|
320
|
+
|
|
321
|
+
<Image
|
|
322
|
+
alt="配置 MinIO 桶策略"
|
|
323
|
+
src="https://github.com/user-attachments/assets/d8109f4e-71fc-4ba8-8402-ede92669d5e0"
|
|
324
|
+
/>
|
|
325
|
+
|
|
326
|
+
4. 在左侧面板 User / Access Keys 处,点击 `Create New Access Key`,无需额外修改,将生成的 `Access Key` 和 `Secret Key` 填入你的 `.env` 文件中的 `S3_ACCESS_KEY_ID` 和 `S3_SECRET_ACCESS_KEY` 中
|
|
327
|
+
|
|
328
|
+
<Image
|
|
329
|
+
alt="创建 MinIO 访问密钥"
|
|
330
|
+
src="https://github.com/user-attachments/assets/72f02ce5-9991-425b-9864-9113ee1ed6bf"
|
|
331
|
+
/>
|
|
332
|
+
|
|
333
|
+
5. 重启 LobeChat 服务:
|
|
334
|
+
|
|
335
|
+
```sh
|
|
336
|
+
docker compose up -d
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
至此,你已经成功部署了 LobeChat 数据库版本,你可以通过 `https://lobe.example.com` 访问你的 LobeChat 服务。
|
|
340
|
+
|
|
341
|
+
## 附录
|
|
342
|
+
|
|
343
|
+
为方便一键复制,在此汇总配置服务端数据库所需要的示例配置文件:
|
|
344
|
+
|
|
345
|
+
### `.env`
|
|
346
|
+
|
|
347
|
+
```sh
|
|
348
|
+
# LobeChat 域名
|
|
349
|
+
APP_URL=https://lobe.example.com/
|
|
350
|
+
|
|
351
|
+
# Postgres 相关,也即 DB 必须的环境变量
|
|
352
|
+
# 用于加密敏感信息的密钥,可以使用 openssl rand -base64 32 生成
|
|
353
|
+
KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ=
|
|
354
|
+
# Postgres 数据库连接字符串
|
|
355
|
+
# 格式:postgres://username:password@host:port/dbname,如果你的 pg 实例为 Docker 容器,请使用容器名
|
|
356
|
+
DATABASE_URL=postgresql://postgres:uWNZugjBqixf8dxC@postgresql:5432/postgres
|
|
357
|
+
|
|
358
|
+
# NEXT_AUTH 相关,可以使用 auth0、Azure AD、GitHub、Authentik、Zitadel、Logto 等,如有其他接入诉求欢迎提 PR
|
|
359
|
+
# 这里以 Logto 为例
|
|
360
|
+
NEXT_AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg
|
|
361
|
+
NEXT_AUTH_SSO_PROVIDERS=logto
|
|
362
|
+
NEXTAUTH_URL=https://lobe.example.com/api/auth
|
|
363
|
+
LOGTO_CLIENT_ID=buc2lpttyo6evdtrfqsur
|
|
364
|
+
LOGTO_CLIENT_SECRET=d97eztx8Ej6aUafeToMAL4jugAKGTAH4
|
|
365
|
+
LOGTO_ISSUER=https://lobe-auth-api.example.com/oidc
|
|
366
|
+
# 注:如果你有 ACCESS_CODE,请务必清空,我们以 NEXT_AUTH 作为唯一鉴权来源
|
|
367
|
+
# Proxy,如果你需要的话(比如你使用 GitHub 作为鉴权服务提供商)
|
|
368
|
+
HTTP_PROXY=http://localhost:7890
|
|
369
|
+
HTTPS_PROXY=http://localhost:7890
|
|
370
|
+
|
|
371
|
+
# MinIO S3 配置
|
|
372
|
+
S3_ACCESS_KEY_ID=YOUR_S3_ACCESS_KEY_ID # 直到在 MinIO UI 中手动创建之前都是无效的
|
|
373
|
+
S3_SECRET_ACCESS_KEY=YOUR_S3_SECRET_ACCESS_KEY # 直到在 MinIO UI 中手动创建之前都是无效的
|
|
374
|
+
S3_ENDPOINT=https://lobe-s3-api.example.com
|
|
375
|
+
S3_BUCKET=lobe # 直到在 MinIO UI 中手动创建之前都是无效的
|
|
376
|
+
S3_PUBLIC_DOMAIN=https://lobe-s3-api.example.com
|
|
377
|
+
S3_ENABLE_PATH_STYLE=1
|
|
378
|
+
|
|
379
|
+
# 其他环境变量,视需求而定,可以参照客户端版本的环境变量配置,注意不要有 ACCESS_CODE
|
|
380
|
+
# OPEANAI_API_KEY=sk-xxxx
|
|
381
|
+
# OPENAI_PROXY_URL=https://api.openai.com/v1
|
|
382
|
+
# OPENAI_MODEL_LIST=...
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### `docker-compose.yml`
|
|
386
|
+
|
|
387
|
+
```yaml
|
|
388
|
+
services:
|
|
389
|
+
postgresql:
|
|
390
|
+
image: pgvector/pgvector:pg16
|
|
391
|
+
container_name: lobe-postgres
|
|
392
|
+
ports:
|
|
393
|
+
- '5432:5432'
|
|
394
|
+
volumes:
|
|
395
|
+
- './data:/var/lib/postgresql/data'
|
|
396
|
+
environment:
|
|
397
|
+
- 'POSTGRES_DB=lobe'
|
|
398
|
+
- 'POSTGRES_PASSWORD=uWNZugjBqixf8dxC'
|
|
399
|
+
healthcheck:
|
|
400
|
+
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
|
401
|
+
interval: 5s
|
|
402
|
+
timeout: 5s
|
|
403
|
+
retries: 5
|
|
404
|
+
restart: always
|
|
405
|
+
|
|
406
|
+
minio:
|
|
407
|
+
image: minio/minio
|
|
408
|
+
container_name: lobe-minio
|
|
409
|
+
ports:
|
|
410
|
+
- '9000:9000'
|
|
411
|
+
- '9001:9001'
|
|
412
|
+
volumes:
|
|
413
|
+
- './s3_data:/etc/minio/data'
|
|
414
|
+
environment:
|
|
415
|
+
- 'MINIO_ROOT_USER=YOUR_MINIO_USER'
|
|
416
|
+
- 'MINIO_ROOT_PASSWORD=YOUR_MINIO_PASSWORD'
|
|
417
|
+
- 'MINIO_DOMAIN=lobe-s3-api.example.com'
|
|
418
|
+
- 'MINIO_API_CORS_ALLOW_ORIGIN=https://lobe.example.com' # 请注意这里的域名是你的 LobeChat 服务端域名
|
|
419
|
+
restart: always
|
|
420
|
+
command: >
|
|
421
|
+
server /etc/minio/data --address ":9000" --console-address ":9001"
|
|
422
|
+
|
|
423
|
+
logto:
|
|
424
|
+
image: svhd/logto
|
|
425
|
+
container_name: lobe-logto
|
|
426
|
+
ports:
|
|
427
|
+
- '3001:3001'
|
|
428
|
+
- '3002:3002'
|
|
429
|
+
depends_on:
|
|
430
|
+
postgresql:
|
|
431
|
+
condition: service_healthy
|
|
432
|
+
environment:
|
|
433
|
+
- 'TRUST_PROXY_HEADER=1'
|
|
434
|
+
- 'DB_URL=postgresql://postgres:uWNZugjBqixf8dxC@postgresql:5432/logto'
|
|
435
|
+
- 'ENDPOINT=https://lobe-auth-api.example.com'
|
|
436
|
+
- 'ADMIN_ENDPOINT=https://lobe-auth-ui.example.com'
|
|
437
|
+
entrypoint: ['sh', '-c', 'npm run cli db seed -- --swe && npm start']
|
|
438
|
+
|
|
439
|
+
lobe:
|
|
440
|
+
image: lobehub/lobe-chat-database
|
|
441
|
+
container_name: lobe-database
|
|
442
|
+
ports:
|
|
443
|
+
- '3210:3210'
|
|
444
|
+
depends_on:
|
|
445
|
+
- postgresql
|
|
446
|
+
- minio
|
|
447
|
+
- logto
|
|
448
|
+
env_file:
|
|
449
|
+
- .env
|
|
450
|
+
restart: always
|
|
451
|
+
|
|
452
|
+
volumes:
|
|
453
|
+
data:
|
|
454
|
+
driver: local
|
|
455
|
+
s3_data:
|
|
456
|
+
driver: local
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### `minio-bucket-config.json`
|
|
460
|
+
|
|
461
|
+
```json
|
|
462
|
+
{
|
|
463
|
+
"Statement": [
|
|
464
|
+
{
|
|
465
|
+
"Effect": "Allow",
|
|
466
|
+
"Principal": {
|
|
467
|
+
"AWS": ["*"]
|
|
468
|
+
},
|
|
469
|
+
"Action": ["s3:GetBucketLocation"],
|
|
470
|
+
"Resource": ["arn:aws:s3:::lobe"]
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"Effect": "Allow",
|
|
474
|
+
"Principal": {
|
|
475
|
+
"AWS": ["*"]
|
|
476
|
+
},
|
|
477
|
+
"Action": ["s3:ListBucket"],
|
|
478
|
+
"Resource": ["arn:aws:s3:::lobe"],
|
|
479
|
+
"Condition": {
|
|
480
|
+
"StringEquals": {
|
|
481
|
+
"s3:prefix": ["files/*"]
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
"Effect": "Allow",
|
|
487
|
+
"Principal": {
|
|
488
|
+
"AWS": ["*"]
|
|
489
|
+
},
|
|
490
|
+
"Action": ["s3:PutObject", "s3:DeleteObject", "s3:GetObject"],
|
|
491
|
+
"Resource": ["arn:aws:s3:::lobe/files/**"]
|
|
492
|
+
}
|
|
493
|
+
],
|
|
494
|
+
"Version": "2012-10-17"
|
|
495
|
+
}
|
|
496
|
+
```
|
|
24
497
|
|
|
25
498
|
[docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat-database
|
|
26
499
|
[docker-pulls-shield]: https://img.shields.io/docker/pulls/lobehub/lobe-chat-database?color=45cc11&labelColor=black&style=flat-square
|
|
@@ -24,6 +24,13 @@ tags:
|
|
|
24
24
|
This article assumes that you are familiar with the basic principles and processes of deploying the LobeChat server database version, so it only includes content related to core environment variable configuration. If you are not familiar with the deployment principles of the LobeChat server database version, please refer to [Deploying Server Database](/en/docs/self-hosting/server-database) first.
|
|
25
25
|
</Callout>
|
|
26
26
|
|
|
27
|
+
<Callout type="warning">
|
|
28
|
+
Due to the inability to expose `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` using Docker environment variables, you cannot use Clerk as an authentication service when deploying LobeChat using Docker / Docker Compose.
|
|
29
|
+
|
|
30
|
+
If you do need Clerk as an authentication service, you might consider deploying using Vercel or building your own image.
|
|
31
|
+
|
|
32
|
+
</Callout>
|
|
33
|
+
|
|
27
34
|
## Deploying on a Linux Server
|
|
28
35
|
|
|
29
36
|
Here is the process for deploying the LobeChat server database version on a Linux server:
|
|
@@ -58,6 +65,8 @@ APP_URL=https://your-prod-domain.com
|
|
|
58
65
|
|
|
59
66
|
# DB required environment variables
|
|
60
67
|
KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
|
|
68
|
+
# Postgres database connection string
|
|
69
|
+
# Format: postgres://username:password@host:port/dbname; if your pg instance is a Docker container, use the container name
|
|
61
70
|
DATABASE_URL=postgres://postgres:mysecretpassword@my-postgres:5432/postgres
|
|
62
71
|
|
|
63
72
|
# NEXT_AUTH related, can use auth0, Azure AD, GitHub, Authentik, zitadel, etc. If you have other access requirements, feel free to submit a PR
|
|
@@ -74,6 +83,11 @@ S3_SECRET_ACCESS_KEY=xxxxxxxxxx
|
|
|
74
83
|
S3_ENDPOINT=https://xxxxxxxxxx.r2.cloudflarestorage.com
|
|
75
84
|
S3_BUCKET=lobechat
|
|
76
85
|
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
86
|
+
|
|
87
|
+
# Other environment variables, as needed. You can refer to the environment variables configuration for the client version, making sure not to have ACCESS_CODE.
|
|
88
|
+
# OPEANAI_API_KEY=sk-xxxx
|
|
89
|
+
# OPENAI_PROXY_URL=https://api.openai.com/v1
|
|
90
|
+
# OPENAI_MODEL_LIST=...
|
|
77
91
|
```
|
|
78
92
|
|
|
79
93
|
### Start the lobe-chat-database Docker image
|
|
@@ -82,6 +96,12 @@ S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
|
82
96
|
docker run -it -d -p 3210:3210 --network pg --env-file lobe-chat.env --name lobe-chat-database lobehub/lobe-chat-database
|
|
83
97
|
```
|
|
84
98
|
|
|
99
|
+
You can use the following command to check the logs:
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
docker logs -f lobe-chat-database
|
|
103
|
+
```
|
|
104
|
+
|
|
85
105
|
If you see the following logs in the container, it means it has started successfully:
|
|
86
106
|
|
|
87
107
|
```log
|
|
@@ -25,6 +25,13 @@ tags:
|
|
|
25
25
|
版的部署原理,请先查阅 [使用服务端数据库部署](/zh/docs/self-hosting/server-database) 。
|
|
26
26
|
</Callout>
|
|
27
27
|
|
|
28
|
+
<Callout type="warning">
|
|
29
|
+
由于无法使用 Docker 环境变量暴露 `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY`,使用 Docker / Docker Compose
|
|
30
|
+
部署 LobeChat 时,你不能使用 Clerk 作为登录鉴权服务。
|
|
31
|
+
|
|
32
|
+
如果你确实需要 Clerk 作为登录鉴权服务,你可以考虑使用 Vercel 部署或者自行构建镜像。
|
|
33
|
+
</Callout>
|
|
34
|
+
|
|
28
35
|
## 在 Linux 服务器上部署
|
|
29
36
|
|
|
30
37
|
以下是在 Linux 服务器上部署 LobeChat DB 版的流程:
|
|
@@ -55,11 +62,14 @@ docker run --name my-postgres --network pg -e POSTGRES_PASSWORD=mysecretpassword
|
|
|
55
62
|
### 创建名为 `lobe-chat.env` 文件用于存放环境变量:
|
|
56
63
|
|
|
57
64
|
```shell
|
|
58
|
-
|
|
65
|
+
# 网站域名
|
|
59
66
|
APP_URL=https://your-prod-domain.com
|
|
60
67
|
|
|
61
68
|
# DB 必须的环境变量
|
|
62
|
-
|
|
69
|
+
# 用于加密敏感信息的密钥,可以使用 openssl rand -base64 32 生成
|
|
70
|
+
KEY_VAULTS_SECRET='jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk='
|
|
71
|
+
# Postgres 数据库连接字符串
|
|
72
|
+
# 格式:postgres://username:password@host:port/dbname,如果你的 pg 实例为 Docker 容器,请使用容器名
|
|
63
73
|
DATABASE_URL=postgres://postgres:mysecretpassword@my-postgres:5432/postgres
|
|
64
74
|
|
|
65
75
|
# NEXT_AUTH 相关,可以使用 auth0、Azure AD、GitHub、Authentik、zitadel 等,如有其他接入诉求欢迎提 PR
|
|
@@ -73,9 +83,16 @@ AUTH0_ISSUER=https://lobe-chat-demo.us.auth0.com
|
|
|
73
83
|
# S3 相关
|
|
74
84
|
S3_ACCESS_KEY_ID=xxxxxxxxxx
|
|
75
85
|
S3_SECRET_ACCESS_KEY=xxxxxxxxxx
|
|
76
|
-
S3_ENDPOINT=https://xxxxxxxxxx.r2.cloudflarestorage.com
|
|
86
|
+
S3_ENDPOINT=https://xxxxxxxxxx.r2.cloudflarestorage.com # 用于 S3 API 访问的域名
|
|
77
87
|
S3_BUCKET=lobechat
|
|
78
|
-
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
88
|
+
S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com # 用于外网访问 S3 的公共域名,需配置 CORS
|
|
89
|
+
# S3_REGION=ap-chengdu # 如果需要指定地域
|
|
90
|
+
|
|
91
|
+
# 其他环境变量,视需求而定
|
|
92
|
+
# OPEANAI_API_KEY=sk-xxxx
|
|
93
|
+
# OPENAI_PROXY_URL=https://api.openai.com/v1
|
|
94
|
+
# OPENAI_MODEL_LIST=...
|
|
95
|
+
# ...
|
|
79
96
|
```
|
|
80
97
|
|
|
81
98
|
### 启动 lobe-chat-database docker 镜像
|
|
@@ -84,6 +101,12 @@ S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
|
|
84
101
|
docker run -it -d -p 3210:3210 --network pg --env-file lobe-chat.env --name lobe-chat-database lobehub/lobe-chat-database
|
|
85
102
|
```
|
|
86
103
|
|
|
104
|
+
你可以使用下述指令检查日志:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
docker logs -f lobe-chat-database
|
|
108
|
+
```
|
|
109
|
+
|
|
87
110
|
如果你在容器中看到了以下日志,则说明已经启动成功:
|
|
88
111
|
|
|
89
112
|
```log
|
|
@@ -21,7 +21,7 @@ tags:
|
|
|
21
21
|
src={'https://github.com/lobehub/lobe-chat/assets/28616219/ecc8364a-cfc4-4a3d-b6fd-68b2d9bc5f0d'}
|
|
22
22
|
/>
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
我们深知在当今多设备环境下为用户提供无缝体验的重要性。为此,我们采用了渐进式 Web 应用 [PWA](https://support.google.com/chrome/answer/9658361) 技术,这是一种能够将网页应用提升至接近原生应用体验的现代 Web 技术。通过 PWA,LobeChat 能够在桌面和移动设备上提供高度优化的用户体验,同时保持轻量级和高性能的特点。在视觉和感觉上,我们也经过精心设计,以确保它的界面与原生应用无差别,提供流畅的动画、响应式布局和适配不同设备的屏幕分辨率。
|
|
25
25
|
|
|
26
26
|
若您未熟悉 PWA 的安装过程,您可以按照以下步骤将 LobeChat 添加为您的桌面应用(也适用于移动设备):
|
|
27
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.4",
|
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"@langchain/community": "^0.2.31",
|
|
120
120
|
"@lobehub/chat-plugin-sdk": "^1.32.4",
|
|
121
121
|
"@lobehub/chat-plugins-gateway": "^1.9.0",
|
|
122
|
-
"@lobehub/icons": "^1.
|
|
122
|
+
"@lobehub/icons": "^1.30.0",
|
|
123
123
|
"@lobehub/tts": "^1.24.3",
|
|
124
124
|
"@lobehub/ui": "^1.149.2",
|
|
125
125
|
"@neondatabase/serverless": "^0.9.4",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { ModelTag } from '@lobehub/icons';
|
|
1
2
|
import isEqual from 'fast-deep-equal';
|
|
2
3
|
import { memo } from 'react';
|
|
3
4
|
import { Flexbox } from 'react-layout-kit';
|
|
4
5
|
|
|
5
|
-
import ModelTag from '@/components/ModelTag';
|
|
6
6
|
import ModelSwitchPanel from '@/features/ModelSwitchPanel';
|
|
7
7
|
import { useAgentStore } from '@/store/agent';
|
|
8
8
|
import { agentSelectors } from '@/store/agent/selectors';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ModelTag } from '@lobehub/icons';
|
|
1
2
|
import { Avatar, ChatHeaderTitle, Markdown } from '@lobehub/ui';
|
|
2
3
|
import { LobeChat } from '@lobehub/ui/brand';
|
|
3
4
|
import { memo } from 'react';
|
|
@@ -5,7 +6,6 @@ import { useTranslation } from 'react-i18next';
|
|
|
5
6
|
import { Flexbox } from 'react-layout-kit';
|
|
6
7
|
|
|
7
8
|
import pkg from '@/../package.json';
|
|
8
|
-
import ModelTag from '@/components/ModelTag';
|
|
9
9
|
import ChatList from '@/features/Conversation/components/ChatList';
|
|
10
10
|
import { useAgentStore } from '@/store/agent';
|
|
11
11
|
import { agentSelectors } from '@/store/agent/selectors';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { ModelTag } from '@lobehub/icons';
|
|
1
2
|
import { memo, useMemo, useState } from 'react';
|
|
2
3
|
import { Flexbox } from 'react-layout-kit';
|
|
3
4
|
import { shallow } from 'zustand/shallow';
|
|
4
5
|
|
|
5
|
-
import ModelTag from '@/components/ModelTag';
|
|
6
6
|
import { useAgentStore } from '@/store/agent';
|
|
7
7
|
import { agentSelectors } from '@/store/agent/selectors';
|
|
8
8
|
import { useChatStore } from '@/store/chat';
|