From 755f8d45c3399de6500d2d7cc13926a5c0f862d3 Mon Sep 17 00:00:00 2001 From: XiaoMo Date: Thu, 8 Jan 2026 11:51:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E9=85=8D=E7=BD=AE=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加.env.example文件并更新Dockerfile和index.js以支持通过环境变量配置API基础路径和缓存目录 --- .env.example | 3 +++ Dockerfile | 2 ++ index.js | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..2b33190 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +PORT=9520 +API_BASE=http://127.0.0.1:9558/api +CACHE_DIR=./.cache \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 06f235a..7b2fc35 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,8 @@ COPY . . # 3. 权限与启动 ENV PORT=9520 ENV CACHE_DIR=/app/.cache +ENV API_BASE=http://127.0.0.1:9558/api +VOLUME ["/app/.cache"] RUN useradd -m appuser && \ mkdir -p "$CACHE_DIR" && \ diff --git a/index.js b/index.js index 817f820..9f83165 100644 --- a/index.js +++ b/index.js @@ -17,8 +17,8 @@ const EventEmitter = require('events'); // Configuration const PORT = process.env.PORT || 9520; -const API_BASE = 'http://183.6.121.121:9558/api'; -const CACHE_DIR = path.join(__dirname, '.cache'); +const API_BASE = process.env.API_BASE || 'http://127.0.0.1:9558/api'; +const CACHE_DIR = process.env.CACHE_DIR ? path.resolve(process.env.CACHE_DIR) : path.join(__dirname, '.cache'); // Ensure cache directory exists if (!fs.existsSync(CACHE_DIR)) {