orztv commited on
Commit
d57197c
·
1 Parent(s): 405ecf3
Files changed (3) hide show
  1. .env +10 -1
  2. Dockerfile +2 -1
  3. run.sh +16 -1
.env CHANGED
@@ -1 +1,10 @@
1
-
 
 
 
 
 
 
 
 
 
 
1
+ # PostgreSQL 配置
2
+ POSTGRES_USER=n8n
3
+ POSTGRES_PASSWORD=your_secure_password
4
+ POSTGRES_DB=n8n
5
+
6
+ # N8N 配置
7
+ N8N_ENCRYPTION_KEY=your_secure_encryption_key
8
+
9
+ # 时区设置
10
+ TZ=Asia/Shanghai
Dockerfile CHANGED
@@ -20,7 +20,7 @@ ENV WEBHOOK_URL=${WEBHOOK_URL} \
20
  QUEUE_HEALTH_CHECK_ACTIVE=true \
21
  N8N_PAYLOAD_SIZE_MAX=256 \
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
 
@@ -41,6 +41,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
41
  tzdata \
42
  htop \
43
  jq \
 
44
  && ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
45
  && dpkg-reconfigure --frontend noninteractive tzdata \
46
  && apt-get clean \
 
20
  QUEUE_HEALTH_CHECK_ACTIVE=true \
21
  N8N_PAYLOAD_SIZE_MAX=256 \
22
  DB_TYPE=postgresdb \
23
+ DB_POSTGRESDB_PORT=5432 \
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
 
 
41
  tzdata \
42
  htop \
43
  jq \
44
+ netcat \
45
  && ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
46
  && dpkg-reconfigure --frontend noninteractive tzdata \
47
  && apt-get clean \
run.sh CHANGED
@@ -1,10 +1,22 @@
1
  #!/bin/bash
 
2
 
3
  current_time=$(date +"%Y-%m-%d %H:%M:%S")
4
  echo "Starting n8n at $current_time"
5
 
 
 
 
 
 
 
 
 
 
 
 
6
  # 设置 N8N 环境变量
7
- export N8N_ENCRYPTION_KEY="n8n8n8n"
8
  # 允许使用所有内建模块
9
  export NODE_FUNCTION_ALLOW_BUILTIN=*
10
  # 允许使用外部 npm 模块
@@ -24,5 +36,8 @@ export EXECUTIONS_DATA_SAVE_ON_PROGRESS=false
24
  # Don't save manually launched executions
25
  export EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
26
 
 
 
 
27
  # 使用绝对路径调用 n8n,添加日志输出
28
  exec n8n start
 
1
  #!/bin/bash
2
+ set -e
3
 
4
  current_time=$(date +"%Y-%m-%d %H:%M:%S")
5
  echo "Starting n8n at $current_time"
6
 
7
+ # 等待 PostgreSQL 就绪
8
+ wait_for_postgres() {
9
+ echo "Waiting for PostgreSQL to start..."
10
+ while ! nc -z ${DB_POSTGRESDB_HOST} ${DB_POSTGRESDB_PORT}; do
11
+ sleep 1
12
+ done
13
+ echo "PostgreSQL started"
14
+ }
15
+
16
+ wait_for_postgres
17
+
18
  # 设置 N8N 环境变量
19
+ export N8N_ENCRYPTION_KEY="${N8N_ENCRYPTION_KEY:-n8n8n8n}"
20
  # 允许使用所有内建模块
21
  export NODE_FUNCTION_ALLOW_BUILTIN=*
22
  # 允许使用外部 npm 模块
 
36
  # Don't save manually launched executions
37
  export EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
38
 
39
+ # 设置文件权限
40
+ export N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
41
+
42
  # 使用绝对路径调用 n8n,添加日志输出
43
  exec n8n start