javaeeduke commited on
Commit
2a2fa33
·
verified ·
1 Parent(s): 47b9f31

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -65
Dockerfile CHANGED
@@ -1,77 +1,20 @@
1
  FROM node:22-alpine
2
 
3
- # 安装基础编译依赖
4
- RUN apk add --no-cache git python3 make g++ sqlite sqlite-dev
5
 
6
  WORKDIR /app
7
 
8
- # 1. 克隆源码
9
- RUN git clone https://github.com/diegosouzapw/OmniRoute.git .
10
 
11
- # 2. 物理抹除导致原生编译挂掉向量库
12
- RUN sed -i '/"sqlite-vec/d' package.json || true
13
- RUN sed -i '/"sqlite-vec-linux-x64/d' package.json || true
14
-
15
- # 3. 完美重构多语言 JSON 文件(彻底降伏 INVALID_KEY)
16
- RUN node -e " \
17
- const fs = require('fs'); \
18
- const path = require('path'); \
19
- function unflatten(data) { \
20
- const result = {}; \
21
- for (const i in data) { \
22
- if (i.includes('.')) { \
23
- const keys = i.split('.'); \
24
- keys.reduce((r, e, j) => { \
25
- return r[e] || (r[e] = keys.length - 1 === j ? data[i] : {}); \
26
- }, result); \
27
- } else { \
28
- result[i] = data[i]; \
29
- } \
30
- } \
31
- return result; \
32
- } \
33
- const localesDir = path.join(process.cwd(), 'messages'); \
34
- if (fs.existsSync(localesDir)) { \
35
- fs.readdirSync(localesDir).forEach(file => { \
36
- if (file.endsWith('.json')) { \
37
- const filePath = path.join(localesDir, file); \
38
- const json = JSON.parse(fs.readFileSync(filePath, 'utf8')); \
39
- if (json.compliance && json.compliance.eventTypes) { \
40
- json.compliance.eventTypes = unflatten(json.compliance.eventTypes); \
41
- } \
42
- fs.writeFileSync(filePath, JSON.stringify(json, null, 2)); \
43
- } \
44
- }); \
45
- } \
46
- "
47
-
48
- # 4. 【核心修正】不让 next.config.mjs 里的检查和原厂脚本坏了大事
49
- # 直接让 Next.js 打包时跳过 TypeScript 错误和 ESLint 错误,强行通过打包
50
- RUN node -e " \
51
- const fs = require('fs'); \
52
- let content = fs.readFileSync('next.config.mjs', 'utf8'); \
53
- const patch = '\n typescript: { ignoreBuildErrors: true },\n eslint: { ignoreDuringBuilds: true },'; \
54
- if (content.includes('nextConfig = {')) { \
55
- content = content.replace('nextConfig = {', 'nextConfig = {' + patch); \
56
- } else if (content.includes('const nextConfig = {')) { \
57
- content = content.replace('const nextConfig = {', 'const nextConfig = {' + patch); \
58
- } \
59
- fs.writeFileSync('next.config.mjs', content); \
60
- "
61
-
62
- # 5. 安装全部依赖并执行原生构建
63
- RUN npm install --include=dev
64
-
65
- ENV NEXT_TELEMETRY_DISABLED=1
66
- # 绕过原厂隔离脚本,直接呼叫原生 Next.js 核心进行硬核打包
67
- RUN npx next build
68
-
69
- # 锁死端口与环境
70
  ENV PORT=7860
71
  ENV OMNIROUTE_PORT=7860
72
  ENV HOST=0.0.0.0
73
  ENV NODE_ENV=production
 
74
  EXPOSE 7860
75
 
76
- # 6. 生产模式拉起,Webpack 热更新彻底退场跨域阻断全剧终!
77
- CMD ["npx", "next", "start", "-p", "7860"]
 
1
  FROM node:22-alpine
2
 
3
+ # 安装运行时必需的基础轻量依赖
4
+ RUN apk add --no-cache sqlite sqlite-dev
5
 
6
  WORKDIR /app
7
 
8
+ # 1. 直接安装官方在全球 npm 仓库上发布好的 omniroute 稳定版编译成品
9
+ RUN npm install -g omniroute
10
 
11
+ # 2. 锁死 Hugging Face 唯一支持 7860 端口
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ENV PORT=7860
13
  ENV OMNIROUTE_PORT=7860
14
  ENV HOST=0.0.0.0
15
  ENV NODE_ENV=production
16
+
17
  EXPOSE 7860
18
 
19
+ # 3. 直接通过全局命令拉起,零编译秒开机
20
+ CMD ["omniroute"]