From 211e8399a982ac7b9e2791c1cd674ea2b4acc0ba Mon Sep 17 00:00:00 2001 From: muzi <444136347@qq.com> Date: Mon, 26 Jan 2026 19:28:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor(n8n):=20=E7=A7=BB=E9=99=A4=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=E9=85=8D=E7=BD=AE=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E9=83=A8=E7=BD=B2=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 .env.example 文件,将默认配置直接写入 docker-compose.yml - 更新 .gitignore 添加 .idea 目录忽略 - 修改 docker-compose.yml 将环境变量硬编码为默认值 - 移除 README.md 中关于复制 .env.example 的说明 - 添加 Mac 平台兼容性配置说明和可选参数设置 --- .env.example | 10 ---------- .gitignore | 3 ++- README.md | 4 +--- docker-compose.yml | 23 +++++++++++++---------- 4 files changed, 16 insertions(+), 24 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index e455aa6..0000000 --- a/.env.example +++ /dev/null @@ -1,10 +0,0 @@ -# n8n 访问端口(本机如果 5678 冲突就改成 5679/5680...) -N8N_PORT=5678 - -# 时区 -TZ=Asia/Shanghai - -# Postgres(默认即可) -POSTGRES_USER=n8n -POSTGRES_PASSWORD=n8npass -POSTGRES_DB=n8n \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0525e16..c75bd4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .env n8n-data/ postgres-data/ -.DS_Store \ No newline at end of file +.DS_Store +.idea \ No newline at end of file diff --git a/README.md b/README.md index 4335cac..3a7c3f7 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,6 @@ git clone <你的仓库地址> cd n8n-local -cp .env.example .env -# 如端口冲突,编辑 .env 修改 N8N_PORT=5679 - docker compose up -d docker compose ps ``` @@ -21,3 +18,4 @@ docker compose ps 备注: - 当前固定使用 `n8nio/n8n:2.2.4` - `postgres` 加了健康检查,`n8n` 会等待数据库就绪后再启动 +- Mac 上如果遇到 `Restarting (139)`,已在 `docker-compose.yml` 中加入 `platform: linux/amd64` 和 `user: "0:0"` diff --git a/docker-compose.yml b/docker-compose.yml index 6e73d36..4d363e9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,14 +4,14 @@ services: container_name: n8n-postgres restart: unless-stopped environment: - POSTGRES_USER: ${POSTGRES_USER} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} - POSTGRES_DB: ${POSTGRES_DB} - TZ: ${TZ} + POSTGRES_USER: n8n + POSTGRES_PASSWORD: n8npass + POSTGRES_DB: n8n + TZ: Asia/Shanghai volumes: - ./postgres-data:/var/lib/postgresql/data healthcheck: - test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] + test: ["CMD-SHELL", "pg_isready -U n8n -d n8n"] interval: 10s timeout: 5s retries: 5 @@ -21,15 +21,18 @@ services: container_name: n8n restart: unless-stopped ports: - - "${N8N_PORT}:5678" + - "5678:5678" + # Mac 上如遇 `Restarting (139)` 可开启以下两项: + # platform: linux/amd64 + # user: "0:0" environment: DB_TYPE: postgresdb DB_POSTGRESDB_HOST: postgres DB_POSTGRESDB_PORT: 5432 - DB_POSTGRESDB_DATABASE: ${POSTGRES_DB} - DB_POSTGRESDB_USER: ${POSTGRES_USER} - DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD} - TZ: ${TZ} + DB_POSTGRESDB_DATABASE: n8n + DB_POSTGRESDB_USER: n8n + DB_POSTGRESDB_PASSWORD: n8npass + TZ: Asia/Shanghai volumes: - ./n8n-data:/home/node/.n8n depends_on: