feat: update Docker configuration and add environment variable documentation

This commit is contained in:
Lan
2026-01-24 11:58:23 +08:00
parent da5dc378a7
commit a35b3c8262
4 changed files with 125 additions and 11 deletions
+14 -1
View File
@@ -38,6 +38,19 @@ COPY --from=frontend-builder /build/fronted-2023/dist ./themes/2023
# 安装 Python 依赖
RUN pip install --no-cache-dir -r requirements.txt
# 环境变量配置
ENV HOST="::" \
PORT=12345 \
WORKERS=4 \
LOG_LEVEL="info"
EXPOSE 12345
CMD ["python", "main.py"]
# 生产环境启动命令
CMD uvicorn main:app \
--host $HOST \
--port $PORT \
--workers $WORKERS \
--log-level $LOG_LEVEL \
--proxy-headers \
--forwarded-allow-ips "*"
+54 -1
View File
@@ -17,8 +17,61 @@ FileCodeBox 是一个简单高效的文件分享工具,支持文件临时中
### Docker 部署(推荐)
#### 快速启动
```bash
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
```
#### Docker Compose
```yml
version: "3"
services:
file-code-box:
image: lanol/filecodebox:latest
volumes:
- fcb-data:/app/data:rw
restart: unless-stopped
ports:
- "12345:12345"
environment:
- WORKERS=4
- LOG_LEVEL=info
volumes:
fcb-data:
external: false
```
#### 环境变量
| 变量 | 默认值 | 说明 |
|------|--------|------|
| `HOST` | `::` | 监听地址,支持 IPv4/IPv6 双栈 |
| `PORT` | `12345` | 服务端口 |
| `WORKERS` | `4` | 工作进程数,建议设置为 CPU 核心数 |
| `LOG_LEVEL` | `info` | 日志级别:debug/info/warning/error |
#### 自定义配置示例
```bash
docker run -d --restart=always \
-p 12345:12345 \
-v /opt/FileCodeBox/:/app/data \
-e WORKERS=8 \
-e LOG_LEVEL=warning \
--name filecodebox \
lanol/filecodebox:latest
```
### 配置反向代理(Nginx
```nginx
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:12345;
}
```
### 手动部署
+26 -2
View File
@@ -193,7 +193,7 @@ FileCodeBox 是一个基于 FastAPI + Vue3 开发的轻量级文件分享工具
#### Docker CLI
```bash
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
```
#### Docker Compose
@@ -208,11 +208,35 @@ services:
restart: unless-stopped
ports:
- "12345:12345"
environment:
- WORKERS=4
- LOG_LEVEL=info
volumes:
fcb-data:
external: false
```
#### 环境变量
| 变量 | 默认值 | 说明 |
|------|--------|------|
| `HOST` | `::` | 监听地址,支持 IPv4/IPv6 双栈 |
| `PORT` | `12345` | 服务端口 |
| `WORKERS` | `4` | 工作进程数,建议设置为 CPU 核心数 |
| `LOG_LEVEL` | `info` | 日志级别:debug/info/warning/error |
**自定义配置示例:**
```bash
docker run -d --restart=always \
-p 12345:12345 \
-v /opt/FileCodeBox/:/app/data \
-e WORKERS=8 \
-e LOG_LEVEL=warning \
--name filecodebox \
lanol/filecodebox:latest
```
### 配置反向代理(Nginx示例)
请注意,必须添加以下配置来确保正确处理客户端IP和代理请求:
@@ -221,7 +245,7 @@ volumes:
location / {
proxy_set_header X-Real-IP $remote_addr; # 设置真实客户端IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:12345;
proxy_pass http://localhost:12345;
}
```
+31 -7
View File
@@ -189,14 +189,14 @@ Command-line download
#### Docker CLI
```bash
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
```
#### Docker Compose
```ymlfix
```yml
version: "3"
services:s
services:
file-code-box:
image: lanol/filecodebox:latest
volumes:
@@ -204,20 +204,44 @@ services:s
restart: unless-stopped
ports:
- "12345:12345"
environment:
- WORKERS=4
- LOG_LEVEL=info
volumes:
fcb-data:
external: false
```
### Configure reverse proxy (Nginx example)
#### Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `HOST` | `::` | Listen address, supports IPv4/IPv6 dual-stack |
| `PORT` | `12345` | Service port |
| `WORKERS` | `4` | Number of worker processes, recommended to set to CPU cores |
| `LOG_LEVEL` | `info` | Log level: debug/info/warning/error |
**Custom configuration example:**
```bash
docker run -d --restart=always \
-p 12345:12345 \
-v /opt/FileCodeBox/:/app/data \
-e WORKERS=8 \
-e LOG_LEVEL=warning \
--name filecodebox \
lanol/filecodebox:latest
```
### Configure Reverse Proxy (Nginx Example)
Please note that the following configurations must be added to ensure proper handling of client IP and proxy requests:
```nginx
location / {
proxy_set_header X-Real-IP $remote_addr; #Set real client IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:12345 ;
proxy_set_header X-Real-IP $remote_addr; # Set real client IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:12345;
}
```