feat: update Docker configuration and add environment variable documentation
This commit is contained in:
+14
-1
@@ -38,6 +38,19 @@ COPY --from=frontend-builder /build/fronted-2023/dist ./themes/2023
|
|||||||
# 安装 Python 依赖
|
# 安装 Python 依赖
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# 环境变量配置
|
||||||
|
ENV HOST="::" \
|
||||||
|
PORT=12345 \
|
||||||
|
WORKERS=4 \
|
||||||
|
LOG_LEVEL="info"
|
||||||
|
|
||||||
EXPOSE 12345
|
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 "*"
|
||||||
@@ -17,8 +17,61 @@ FileCodeBox 是一个简单高效的文件分享工具,支持文件临时中
|
|||||||
|
|
||||||
### Docker 部署(推荐)
|
### Docker 部署(推荐)
|
||||||
|
|
||||||
|
#### 快速启动
|
||||||
|
|
||||||
```bash
|
```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;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 手动部署
|
### 手动部署
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ FileCodeBox 是一个基于 FastAPI + Vue3 开发的轻量级文件分享工具
|
|||||||
#### Docker CLI
|
#### Docker CLI
|
||||||
|
|
||||||
```bash
|
```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
|
#### Docker Compose
|
||||||
@@ -208,11 +208,35 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "12345:12345"
|
- "12345:12345"
|
||||||
|
environment:
|
||||||
|
- WORKERS=4
|
||||||
|
- LOG_LEVEL=info
|
||||||
volumes:
|
volumes:
|
||||||
fcb-data:
|
fcb-data:
|
||||||
external: false
|
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示例)
|
||||||
|
|
||||||
请注意,必须添加以下配置来确保正确处理客户端IP和代理请求:
|
请注意,必须添加以下配置来确保正确处理客户端IP和代理请求:
|
||||||
@@ -221,7 +245,7 @@ volumes:
|
|||||||
location / {
|
location / {
|
||||||
proxy_set_header X-Real-IP $remote_addr; # 设置真实客户端IP
|
proxy_set_header X-Real-IP $remote_addr; # 设置真实客户端IP
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_pass http://localhost:12345;
|
proxy_pass http://localhost:12345;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+31
-7
@@ -189,14 +189,14 @@ Command-line download
|
|||||||
#### Docker CLI
|
#### Docker CLI
|
||||||
|
|
||||||
```bash
|
```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
|
#### Docker Compose
|
||||||
|
|
||||||
```ymlfix
|
```yml
|
||||||
version: "3"
|
version: "3"
|
||||||
services:s
|
services:
|
||||||
file-code-box:
|
file-code-box:
|
||||||
image: lanol/filecodebox:latest
|
image: lanol/filecodebox:latest
|
||||||
volumes:
|
volumes:
|
||||||
@@ -204,20 +204,44 @@ services:s
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "12345:12345"
|
- "12345:12345"
|
||||||
|
environment:
|
||||||
|
- WORKERS=4
|
||||||
|
- LOG_LEVEL=info
|
||||||
volumes:
|
volumes:
|
||||||
fcb-data:
|
fcb-data:
|
||||||
external: false
|
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:
|
Please note that the following configurations must be added to ensure proper handling of client IP and proxy requests:
|
||||||
|
|
||||||
```nginx
|
```nginx
|
||||||
location / {
|
location / {
|
||||||
proxy_set_header X-Real-IP $remote_addr; #Set real client IP
|
proxy_set_header X-Real-IP $remote_addr; # Set real client IP
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_pass http://localhost:12345 ;
|
proxy_pass http://localhost:12345;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user