Update Dockerfile
Browse files- Dockerfile +43 -7
Dockerfile
CHANGED
|
@@ -1,11 +1,10 @@
|
|
| 1 |
# 使用する Node.js のバージョンを指定
|
| 2 |
FROM node:24.8.0
|
| 3 |
|
| 4 |
-
|
| 5 |
# ポートの公開
|
| 6 |
EXPOSE 7860
|
| 7 |
|
| 8 |
-
#
|
| 9 |
ENV N8N_PORT=7860
|
| 10 |
ENV WEBHOOK_URL=https://stnh70-n8n2.hf.space/
|
| 11 |
ENV VUE_APP_URL_BASE_API=https://stnh70-n8n2.hf.space/
|
|
@@ -13,9 +12,46 @@ ENV VUE_APP_URL_BASE_API=https://stnh70-n8n2.hf.space/
|
|
| 13 |
# n8n のグローバルインストール
|
| 14 |
RUN npm install n8n -g
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
CMD ["
|
|
|
|
| 1 |
# 使用する Node.js のバージョンを指定
|
| 2 |
FROM node:24.8.0
|
| 3 |
|
|
|
|
| 4 |
# ポートの公開
|
| 5 |
EXPOSE 7860
|
| 6 |
|
| 7 |
+
# 环境变量的设置
|
| 8 |
ENV N8N_PORT=7860
|
| 9 |
ENV WEBHOOK_URL=https://stnh70-n8n2.hf.space/
|
| 10 |
ENV VUE_APP_URL_BASE_API=https://stnh70-n8n2.hf.space/
|
|
|
|
| 12 |
# n8n のグローバルインストール
|
| 13 |
RUN npm install n8n -g
|
| 14 |
|
| 15 |
+
# 创建启动脚本目录
|
| 16 |
+
RUN mkdir -p /app
|
| 17 |
+
|
| 18 |
+
# 创建带心跳监控的启动脚本
|
| 19 |
+
RUN cat > /app/start-with-heartbeat.js << 'EOF'
|
| 20 |
+
const { spawn } = require('child_process');
|
| 21 |
+
|
| 22 |
+
// Periodic heartbeat to confirm event loop activity (can be removed later)
|
| 23 |
+
let hbCount = 0;
|
| 24 |
+
setInterval(()=>{
|
| 25 |
+
hbCount++;
|
| 26 |
+
if (hbCount % 6 === 0) { // every 60s if interval is 10s
|
| 27 |
+
console.log('[diagnostic] heartbeat 60s elapsed, process alive');
|
| 28 |
+
}
|
| 29 |
+
}, 10_000).unref();
|
| 30 |
+
|
| 31 |
+
// 启动 n8n
|
| 32 |
+
console.log('[diagnostic] Starting n8n with heartbeat monitoring...');
|
| 33 |
+
const n8nProcess = spawn('n8n', ['start'], {
|
| 34 |
+
stdio: 'inherit',
|
| 35 |
+
env: process.env
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
+
// 处理进程退出
|
| 39 |
+
n8nProcess.on('exit', (code, signal) => {
|
| 40 |
+
console.log(`[diagnostic] n8n process exited with code ${code}, signal ${signal}`);
|
| 41 |
+
process.exit(code);
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
// 处理脚本退出时的信号
|
| 45 |
+
process.on('SIGTERM', () => {
|
| 46 |
+
console.log('[diagnostic] Received SIGTERM, shutting down gracefully...');
|
| 47 |
+
n8nProcess.kill('SIGTERM');
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
process.on('SIGINT', () => {
|
| 51 |
+
console.log('[diagnostic] Received SIGINT, shutting down gracefully...');
|
| 52 |
+
n8nProcess.kill('SIGINT');
|
| 53 |
+
});
|
| 54 |
+
EOF
|
| 55 |
|
| 56 |
+
# 使用带心跳监控的启动脚本
|
| 57 |
+
CMD ["node", "/app/start-with-heartbeat.js"]
|