orztv commited on
Commit
0069402
·
1 Parent(s): f0cbeae
Files changed (2) hide show
  1. Dockerfile +9 -1
  2. run.sh +21 -0
Dockerfile CHANGED
@@ -22,7 +22,13 @@ ENV WEBHOOK_URL=${WEBHOOK_URL} \
22
  DB_TYPE=postgresdb \
23
  DB_POSTGRESDB_PORT=${POSTGRESDB_PORT} \
24
  VIRTUAL_ENV=/home/pn/venv \
25
- PATH="/home/pn/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
 
 
 
 
 
 
26
 
27
  # 安装系统依赖
28
  RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -42,6 +48,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
42
  htop \
43
  jq \
44
  netcat-openbsd \
 
 
45
  && ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
46
  && dpkg-reconfigure --frontend noninteractive tzdata \
47
  && apt-get clean \
 
22
  DB_TYPE=postgresdb \
23
  DB_POSTGRESDB_PORT=${POSTGRESDB_PORT} \
24
  VIRTUAL_ENV=/home/pn/venv \
25
+ PATH="/home/pn/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH" \
26
+ # 添加 Redis 配置
27
+ QUEUE_BULL_REDIS_HOST=localhost \
28
+ QUEUE_BULL_REDIS_PORT=6379 \
29
+ QUEUE_BULL_REDIS_DB=0 \
30
+ N8N_QUEUE_BULL_REDIS_PREFIX=n8n:queue \
31
+ EXECUTIONS_MODE=queue
32
 
33
  # 安装系统依赖
34
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
48
  htop \
49
  jq \
50
  netcat-openbsd \
51
+ # 添加 Redis 安装
52
+ redis-server \
53
  && ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
54
  && dpkg-reconfigure --frontend noninteractive tzdata \
55
  && apt-get clean \
run.sh CHANGED
@@ -25,7 +25,21 @@ wait_for_postgres() {
25
  echo "PostgreSQL started"
26
  }
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  wait_for_postgres
 
29
 
30
  # 设置 N8N 环境变量
31
  export N8N_ENCRYPTION_KEY="${N8N_ENCRYPTION_KEY:-n8n8n8n}"
@@ -47,6 +61,10 @@ export EXECUTIONS_DATA_SAVE_ON_SUCCESS=all
47
  export EXECUTIONS_DATA_SAVE_ON_PROGRESS=false
48
  # Don't save manually launched executions
49
  export EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
 
 
 
 
50
 
51
  # 设置文件权限
52
  export N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
@@ -56,6 +74,9 @@ echo "N8N_HOST: ${N8N_HOST}"
56
  echo "N8N_PORT: ${N8N_PORT}"
57
  echo "N8N_PROTOCOL: ${N8N_PROTOCOL}"
58
  echo "WEBHOOK_URL: ${WEBHOOK_URL}"
 
 
 
59
 
60
  # 使用绝对路径调用 n8n,添加日志输出
61
  exec n8n start
 
25
  echo "PostgreSQL started"
26
  }
27
 
28
+ # 启动 Redis 服务
29
+ start_redis() {
30
+ echo "Starting Redis server..."
31
+ redis-server --daemonize yes
32
+ sleep 1
33
+ if redis-cli ping > /dev/null 2>&1; then
34
+ echo "Redis server started successfully"
35
+ else
36
+ echo "Failed to start Redis server"
37
+ exit 1
38
+ fi
39
+ }
40
+
41
  wait_for_postgres
42
+ start_redis
43
 
44
  # 设置 N8N 环境变量
45
  export N8N_ENCRYPTION_KEY="${N8N_ENCRYPTION_KEY:-n8n8n8n}"
 
61
  export EXECUTIONS_DATA_SAVE_ON_PROGRESS=false
62
  # Don't save manually launched executions
63
  export EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
64
+ # 将以下环境变量设置为 false,以阻止 n8n 连接到其服务器
65
+ export N8N_DIAGNOSTICS_ENABLED=false
66
+ export N8N_VERSION_NOTIFICATIONS_ENABLED=true
67
+ export N8N_TEMPLATES_ENABLED=false
68
 
69
  # 设置文件权限
70
  export N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
 
74
  echo "N8N_PORT: ${N8N_PORT}"
75
  echo "N8N_PROTOCOL: ${N8N_PROTOCOL}"
76
  echo "WEBHOOK_URL: ${WEBHOOK_URL}"
77
+ echo "QUEUE_BULL_REDIS_HOST: ${QUEUE_BULL_REDIS_HOST}"
78
+ echo "QUEUE_BULL_REDIS_PORT: ${QUEUE_BULL_REDIS_PORT}"
79
+ echo "EXECUTIONS_MODE: ${EXECUTIONS_MODE}"
80
 
81
  # 使用绝对路径调用 n8n,添加日志输出
82
  exec n8n start