@lobehub/chat 1.8.1 → 1.8.2

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 CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.8.2](https://github.com/lobehub/lobe-chat/compare/v1.8.1...v1.8.2)
6
+
7
+ <sup>Released on **2024-08-03**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Add `PROXY_URL` in docker with proxychains-ng.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Add `PROXY_URL` in docker with proxychains-ng, closes [#3362](https://github.com/lobehub/lobe-chat/issues/3362) ([920de7c](https://github.com/lobehub/lobe-chat/commit/920de7c))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 1.8.1](https://github.com/lobehub/lobe-chat/compare/v1.8.0...v1.8.1)
6
31
 
7
32
  <sup>Released on **2024-08-03**</sup>
package/Dockerfile CHANGED
@@ -1,15 +1,27 @@
1
1
  ## Base image for all the stages
2
2
  FROM node:20-alpine AS base
3
3
 
4
+ ARG USE_CN_MIRROR
5
+
4
6
  RUN \
7
+ # If you want to build docker in China, build with --build-arg USE_CN_MIRROR=true
8
+ if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
9
+ sed -i "s/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g" "/etc/apk/repositories"; \
10
+ fi \
11
+ # Add proxychains-ng package & update base package
12
+ && apk update \
13
+ && apk add --no-cache proxychains-ng \
14
+ && apk upgrade --no-cache \
5
15
  # Add user nextjs to run the app
6
- addgroup --system --gid 1001 nodejs \
7
- && adduser --system --uid 1001 nextjs
16
+ && addgroup --system --gid 1001 nodejs \
17
+ && adduser --system --uid 1001 nextjs \
18
+ && chown -R nextjs:nodejs "/etc/proxychains" \
19
+ && rm -rf /tmp/* /var/cache/apk/*
8
20
 
9
21
  ## Builder image, install all the dependencies and build the app
10
22
  FROM base AS builder
11
23
 
12
- ARG USE_NPM_CN_MIRROR
24
+ ARG USE_CN_MIRROR
13
25
 
14
26
  ENV NEXT_PUBLIC_BASE_PATH=""
15
27
 
@@ -37,8 +49,8 @@ COPY package.json ./
37
49
  COPY .npmrc ./
38
50
 
39
51
  RUN \
40
- # If you want to build docker in China, build with --build-arg USE_NPM_CN_MIRROR=true
41
- if [ "${USE_NPM_CN_MIRROR:-false}" = "true" ]; then \
52
+ # If you want to build docker in China, build with --build-arg USE_CN_MIRROR=true
53
+ if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
42
54
  export SENTRYCLI_CDNURL="https://npmmirror.com/mirrors/sentry-cli"; \
43
55
  npm config set registry "https://registry.npmmirror.com/"; \
44
56
  fi \
@@ -85,7 +97,10 @@ ENV HOSTNAME="0.0.0.0" \
85
97
  # General Variables
86
98
  ENV ACCESS_CODE="" \
87
99
  API_KEY_SELECT_MODE="" \
88
- FEATURE_FLAGS=""
100
+ DEFAULT_AGENT_CONFIG="" \
101
+ SYSTEM_AGENT="" \
102
+ FEATURE_FLAGS="" \
103
+ PROXY_URL=""
89
104
 
90
105
  # Model Variables
91
106
  ENV \
@@ -138,4 +153,36 @@ USER nextjs
138
153
 
139
154
  EXPOSE 3210/tcp
140
155
 
141
- CMD ["node", "/app/server.js"]
156
+ CMD \
157
+ if [ -n "$PROXY_URL" ]; then \
158
+ # Set regex for IPv4
159
+ IP_REGEX="^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$"; \
160
+ # Set proxychains command
161
+ PROXYCHAINS="proxychains -q"; \
162
+ # Parse the proxy URL
163
+ host_with_port="${PROXY_URL#*//}"; \
164
+ host="${host_with_port%%:*}"; \
165
+ port="${PROXY_URL##*:}"; \
166
+ protocol="${PROXY_URL%%://*}"; \
167
+ # Resolve to IP address if the host is a domain
168
+ if ! [[ "$host" =~ "$IP_REGEX" ]]; then \
169
+ nslookup=$(nslookup -q="A" "$host" | tail -n +3 | grep 'Address:'); \
170
+ if [ -n "$nslookup" ]; then \
171
+ host=$(echo "$nslookup" | tail -n 1 | awk '{print $2}'); \
172
+ fi; \
173
+ fi; \
174
+ # Generate proxychains configuration file
175
+ printf "%s\n" \
176
+ 'localnet 127.0.0.0/255.0.0.0' \
177
+ 'localnet ::1/128' \
178
+ 'proxy_dns' \
179
+ 'remote_dns_subnet 224' \
180
+ 'strict_chain' \
181
+ 'tcp_connect_time_out 8000' \
182
+ 'tcp_read_time_out 15000' \
183
+ '[ProxyList]' \
184
+ "$protocol $host $port" \
185
+ > "/etc/proxychains/proxychains.conf"; \
186
+ fi; \
187
+ # Run the server
188
+ ${PROXYCHAINS} node "/app/server.js";
@@ -80,6 +80,17 @@ Further reading:
80
80
 
81
81
  For specific content, please refer to the [Feature Flags](/docs/self-hosting/advanced/feature-flags) documentation.
82
82
 
83
+ ### `PROXY_URL`
84
+
85
+ - Type: Optional
86
+ - Description: Used to specify the proxy URL for connecting to external services. The value of this variable should be different in different deployment environments.
87
+ - Default: -
88
+ - Example: `http://127.0.0.1:7890` or `socks5://localhost:7891`
89
+
90
+ <Callout type="info">
91
+ If you're using Docker Desktop on Windows or macOS, it relies on a virtual machine. In this setup, `localhost` / `127.0.0.1` refers to the localhost of the container itself. In such cases, please try using `host.docker.internal` instead of `localhost`.
92
+ </Callout>
93
+
83
94
  ## Plugin Service
84
95
 
85
96
  ### `PLUGINS_INDEX_URL`
@@ -76,6 +76,18 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
76
76
 
77
77
  具体的内容可以参见 [特性标志](/zh/docs/self-hosting/advanced/feature-flags) 中的说明。
78
78
 
79
+ ### `PROXY_URL`
80
+
81
+ - 类型:可选
82
+ - 描述:用于指定连接到外部服务的代理 URL。该变量的值在不同的部署环境中应该有所不同。
83
+ - 默认值:-
84
+ - 示例:`http://127.0.0.1:7890` 或 `socks5://localhost:7891`
85
+
86
+
87
+ <Callout type="info">
88
+ `Docker Desktop` 在 `Windows `和 `macOS `上走的是虚拟机方案,如果是 `localhost` / `127.0.0.1` 是走到自身容器的 `localhost`,此时请尝试用 `host.docker.internal` 替代 `localhost`
89
+ </Callout>
90
+
79
91
  ## 插件服务
80
92
 
81
93
  ### `PLUGINS_INDEX_URL`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
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",
@@ -54,7 +54,7 @@
54
54
  "pull": "git pull",
55
55
  "release": "semantic-release",
56
56
  "self-hosting:docker": "docker build -t lobe-chat:local .",
57
- "self-hosting:docker-cn": "docker build -t lobe-chat:local --build-arg USE_NPM_CN_MIRROR=true .",
57
+ "self-hosting:docker-cn": "docker build -t lobe-chat:local --build-arg USE_CN_MIRROR=true .",
58
58
  "start": "next start -p 3210",
59
59
  "stylelint": "stylelint \"src/**/*.{js,jsx,ts,tsx}\" --fix",
60
60
  "test": "npm run test-app && npm run test-server",