Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +12 -44
Dockerfile
CHANGED
|
@@ -12,54 +12,22 @@ RUN git clone https://github.com/diegosouzapw/OmniRoute.git .
|
|
| 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.
|
| 16 |
-
# 全部完美重构为带层级的对象(正如报错日志里 lodash.set 提示的那样)
|
| 17 |
-
RUN node -e " \
|
| 18 |
-
const fs = require('fs'); \
|
| 19 |
-
const path = require('path'); \
|
| 20 |
-
function unflatten(data) { \
|
| 21 |
-
const result = {}; \
|
| 22 |
-
for (const i in data) { \
|
| 23 |
-
if (i.includes('.')) { \
|
| 24 |
-
const keys = i.split('.'); \
|
| 25 |
-
keys.reduce((r, e, j) => { \
|
| 26 |
-
return r[e] || (r[e] = keys.length - 1 === j ? data[i] : {}); \
|
| 27 |
-
}, result); \
|
| 28 |
-
} else { \
|
| 29 |
-
result[i] = data[i]; \
|
| 30 |
-
} \
|
| 31 |
-
} \
|
| 32 |
-
return result; \
|
| 33 |
-
} \
|
| 34 |
-
const localesDir = path.join(process.cwd(), 'messages'); \
|
| 35 |
-
if (fs.existsSync(localesDir)) { \
|
| 36 |
-
fs.readdirSync(localesDir).forEach(file => { \
|
| 37 |
-
if (file.endsWith('.json')) { \
|
| 38 |
-
const filePath = path.join(localesDir, file); \
|
| 39 |
-
const json = JSON.parse(fs.readFileSync(filePath, 'utf8')); \
|
| 40 |
-
if (json.compliance && json.compliance.eventTypes) { \
|
| 41 |
-
json.compliance.eventTypes = unflatten(json.compliance.eventTypes); \
|
| 42 |
-
} \
|
| 43 |
-
fs.writeFileSync(filePath, JSON.stringify(json, null, 2)); \
|
| 44 |
-
console.log('Successfully patched translation file:', file); \
|
| 45 |
-
} \
|
| 46 |
-
}); \
|
| 47 |
-
} \
|
| 48 |
-
"
|
| 49 |
-
|
| 50 |
-
# 4. 干净安装所有依赖
|
| 51 |
RUN npm install --include=dev
|
| 52 |
|
| 53 |
-
#
|
| 54 |
-
ENV NEXT_TELEMETRY_DISABLED=1
|
| 55 |
-
RUN npm run build
|
| 56 |
-
|
| 57 |
-
# 锁死端口
|
| 58 |
ENV PORT=7860
|
| 59 |
ENV OMNIROUTE_PORT=7860
|
| 60 |
ENV HOST=0.0.0.0
|
| 61 |
-
ENV NODE_ENV=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
EXPOSE 7860
|
| 63 |
|
| 64 |
-
#
|
| 65 |
-
|
|
|
|
|
|
| 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. 干净安装所有依赖
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
RUN npm install --include=dev
|
| 17 |
|
| 18 |
+
# 4. 【核心黑魔法】配置环境变量,锁死端口,并硬编码禁用 Next.js 的开发服务器热更新
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
ENV PORT=7860
|
| 20 |
ENV OMNIROUTE_PORT=7860
|
| 21 |
ENV HOST=0.0.0.0
|
| 22 |
+
ENV NODE_ENV=development
|
| 23 |
+
|
| 24 |
+
# 强行给 Webpack/Turbopack 注入禁用热更新和客户端内联 overlay 的参数,
|
| 25 |
+
# 从根源上让网页不再去请求 /_next/webpack-hmr
|
| 26 |
+
ENV NEXT_AMD_DISABLE=1
|
| 27 |
+
ENV WATCHPACK_POLLING=true
|
| 28 |
+
|
| 29 |
EXPOSE 7860
|
| 30 |
|
| 31 |
+
# 5. 直接用 dev 模式拉起,让页面动态渲染,绕过一切恶心的打包静态检查
|
| 32 |
+
# 通过环境变量和参数让它变成一个不带热更新的“伪生产”开发服务器
|
| 33 |
+
CMD ["npm", "run", "dev"]
|