Skip to content

Commit a35b3c8

Browse files
committed
feat: update Docker configuration and add environment variable documentation
1 parent da5dc37 commit a35b3c8

File tree

4 files changed

+125
-11
lines changed

4 files changed

+125
-11
lines changed

Dockerfile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ COPY --from=frontend-builder /build/fronted-2023/dist ./themes/2023
3838
# 安装 Python 依赖
3939
RUN pip install --no-cache-dir -r requirements.txt
4040

41+
# 环境变量配置
42+
ENV HOST="::" \
43+
PORT=12345 \
44+
WORKERS=4 \
45+
LOG_LEVEL="info"
46+
4147
EXPOSE 12345
4248

43-
CMD ["python", "main.py"]
49+
# 生产环境启动命令
50+
CMD uvicorn main:app \
51+
--host $HOST \
52+
--port $PORT \
53+
--workers $WORKERS \
54+
--log-level $LOG_LEVEL \
55+
--proxy-headers \
56+
--forwarded-allow-ips "*"

docs/guide/getting-started.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,61 @@ FileCodeBox 是一个简单高效的文件分享工具,支持文件临时中
1717

1818
### Docker 部署(推荐)
1919

20+
#### 快速启动
21+
22+
```bash
23+
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
24+
```
25+
26+
#### Docker Compose
27+
28+
```yml
29+
version: "3"
30+
services:
31+
file-code-box:
32+
image: lanol/filecodebox:latest
33+
volumes:
34+
- fcb-data:/app/data:rw
35+
restart: unless-stopped
36+
ports:
37+
- "12345:12345"
38+
environment:
39+
- WORKERS=4
40+
- LOG_LEVEL=info
41+
volumes:
42+
fcb-data:
43+
external: false
44+
```
45+
46+
#### 环境变量
47+
48+
| 变量 | 默认值 | 说明 |
49+
|------|--------|------|
50+
| `HOST` | `::` | 监听地址,支持 IPv4/IPv6 双栈 |
51+
| `PORT` | `12345` | 服务端口 |
52+
| `WORKERS` | `4` | 工作进程数,建议设置为 CPU 核心数 |
53+
| `LOG_LEVEL` | `info` | 日志级别:debug/info/warning/error |
54+
55+
#### 自定义配置示例
56+
2057
```bash
21-
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta
58+
docker run -d --restart=always \
59+
-p 12345:12345 \
60+
-v /opt/FileCodeBox/:/app/data \
61+
-e WORKERS=8 \
62+
-e LOG_LEVEL=warning \
63+
--name filecodebox \
64+
lanol/filecodebox:latest
65+
```
66+
67+
### 配置反向代理(Nginx)
68+
69+
```nginx
70+
location / {
71+
proxy_set_header X-Real-IP $remote_addr;
72+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
73+
proxy_pass http://localhost:12345;
74+
}
2275
```
2376

2477
### 手动部署

readme.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ FileCodeBox 是一个基于 FastAPI + Vue3 开发的轻量级文件分享工具
193193
#### Docker CLI
194194

195195
```bash
196-
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta
196+
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
197197
```
198198

199199
#### Docker Compose
@@ -208,11 +208,35 @@ services:
208208
restart: unless-stopped
209209
ports:
210210
- "12345:12345"
211+
environment:
212+
- WORKERS=4
213+
- LOG_LEVEL=info
211214
volumes:
212215
fcb-data:
213216
external: false
214217
```
215218
219+
#### 环境变量
220+
221+
| 变量 | 默认值 | 说明 |
222+
|------|--------|------|
223+
| `HOST` | `::` | 监听地址,支持 IPv4/IPv6 双栈 |
224+
| `PORT` | `12345` | 服务端口 |
225+
| `WORKERS` | `4` | 工作进程数,建议设置为 CPU 核心数 |
226+
| `LOG_LEVEL` | `info` | 日志级别:debug/info/warning/error |
227+
228+
**自定义配置示例:**
229+
230+
```bash
231+
docker run -d --restart=always \
232+
-p 12345:12345 \
233+
-v /opt/FileCodeBox/:/app/data \
234+
-e WORKERS=8 \
235+
-e LOG_LEVEL=warning \
236+
--name filecodebox \
237+
lanol/filecodebox:latest
238+
```
239+
216240
### 配置反向代理(Nginx示例)
217241

218242
请注意,必须添加以下配置来确保正确处理客户端IP和代理请求:
@@ -221,7 +245,7 @@ volumes:
221245
location / {
222246
proxy_set_header X-Real-IP $remote_addr; # 设置真实客户端IP
223247
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
224-
proxy_pass http://localhost:12345;
248+
proxy_pass http://localhost:12345;
225249
}
226250
```
227251

readme_en.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,35 +189,59 @@ Command-line download
189189
#### Docker CLI
190190

191191
```bash
192-
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta
192+
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
193193
```
194194

195195
#### Docker Compose
196196

197-
```ymlfix
197+
```yml
198198
version: "3"
199-
services:s
199+
services:
200200
file-code-box:
201201
image: lanol/filecodebox:latest
202202
volumes:
203203
- fcb-data:/app/data:rw
204204
restart: unless-stopped
205205
ports:
206206
- "12345:12345"
207+
environment:
208+
- WORKERS=4
209+
- LOG_LEVEL=info
207210
volumes:
208211
fcb-data:
209212
external: false
210213
```
211214
212-
### Configure reverse proxy (Nginx example)
215+
#### Environment Variables
216+
217+
| Variable | Default | Description |
218+
|----------|---------|-------------|
219+
| `HOST` | `::` | Listen address, supports IPv4/IPv6 dual-stack |
220+
| `PORT` | `12345` | Service port |
221+
| `WORKERS` | `4` | Number of worker processes, recommended to set to CPU cores |
222+
| `LOG_LEVEL` | `info` | Log level: debug/info/warning/error |
223+
224+
**Custom configuration example:**
225+
226+
```bash
227+
docker run -d --restart=always \
228+
-p 12345:12345 \
229+
-v /opt/FileCodeBox/:/app/data \
230+
-e WORKERS=8 \
231+
-e LOG_LEVEL=warning \
232+
--name filecodebox \
233+
lanol/filecodebox:latest
234+
```
235+
236+
### Configure Reverse Proxy (Nginx Example)
213237

214238
Please note that the following configurations must be added to ensure proper handling of client IP and proxy requests:
215239

216240
```nginx
217241
location / {
218-
proxy_set_header X-Real-IP $remote_addr; #Set real client IP
219-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
220-
proxy_pass http://localhost:12345 ;
242+
proxy_set_header X-Real-IP $remote_addr; # Set real client IP
243+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
244+
proxy_pass http://localhost:12345;
221245
}
222246
```
223247

0 commit comments

Comments
 (0)