timindev commited on
Commit
5c42062
·
verified ·
1 Parent(s): 233206d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -4
Dockerfile CHANGED
@@ -1,3 +1,4 @@
 
1
  FROM node:18-slim
2
 
3
  # 安装 git
@@ -11,12 +12,16 @@ RUN git clone https://github.com/titaniumnetwork-dev/Ultraviolet-App.git .
11
  # 安装依赖
12
  RUN npm install
13
 
14
- # --- 关键修复:手动修复 index.js 中的路径错误 ---
15
- # 使用 sed 命令将 res.sendFile(path) 替换为 res.sendFile(path, { root: '/app/public' })
16
- # 注意:Ultraviolet-App 的静态目录通常是 public 或 static,这里根据源码逻辑调整
17
- RUN sed -i 's/res.sendFile(\([^,)]*\))/res.sendFile(\1, { root: process.cwd() + "\/public" })/g' src/index.js || true
18
 
 
19
  ENV PORT=7860
 
 
20
  EXPOSE 7860
21
 
 
22
  CMD ["npm", "start"]
 
1
+ # 使用 Node.js 18 镜像
2
  FROM node:18-slim
3
 
4
  # 安装 git
 
12
  # 安装依赖
13
  RUN npm install
14
 
15
+ # --- 核心修复:修复绝对路径报错 ---
16
+ # 这个 sed 命令会把 res.sendFile(path) 替换为兼容绝对路径的写法
17
+ # 它会强制指向 /app/public 目录
18
+ RUN sed -i 's|res.sendFile(\([^,)]*\))|res.sendFile(\1, { root: "/app/public" })|g' src/index.js || true
19
 
20
+ # 设置环境变量
21
  ENV PORT=7860
22
+ ENV NODE_ENV=production
23
+
24
  EXPOSE 7860
25
 
26
+ # 启动
27
  CMD ["npm", "start"]