refactor(n8n): 移除环境变量配置简化本地部署流程
- 删除 .env.example 文件,将默认配置直接写入 docker-compose.yml - 更新 .gitignore 添加 .idea 目录忽略 - 修改 docker-compose.yml 将环境变量硬编码为默认值 - 移除 README.md 中关于复制 .env.example 的说明 - 添加 Mac 平台兼容性配置说明和可选参数设置
This commit is contained in:
10
.env.example
10
.env.example
@ -1,10 +0,0 @@
|
|||||||
# n8n 访问端口(本机如果 5678 冲突就改成 5679/5680...)
|
|
||||||
N8N_PORT=5678
|
|
||||||
|
|
||||||
# 时区
|
|
||||||
TZ=Asia/Shanghai
|
|
||||||
|
|
||||||
# Postgres(默认即可)
|
|
||||||
POSTGRES_USER=n8n
|
|
||||||
POSTGRES_PASSWORD=n8npass
|
|
||||||
POSTGRES_DB=n8n
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
n8n-data/
|
n8n-data/
|
||||||
postgres-data/
|
postgres-data/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.idea
|
||||||
@ -11,9 +11,6 @@
|
|||||||
git clone <你的仓库地址>
|
git clone <你的仓库地址>
|
||||||
cd n8n-local
|
cd n8n-local
|
||||||
|
|
||||||
cp .env.example .env
|
|
||||||
# 如端口冲突,编辑 .env 修改 N8N_PORT=5679
|
|
||||||
|
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
docker compose ps
|
docker compose ps
|
||||||
```
|
```
|
||||||
@ -21,3 +18,4 @@ docker compose ps
|
|||||||
备注:
|
备注:
|
||||||
- 当前固定使用 `n8nio/n8n:2.2.4`
|
- 当前固定使用 `n8nio/n8n:2.2.4`
|
||||||
- `postgres` 加了健康检查,`n8n` 会等待数据库就绪后再启动
|
- `postgres` 加了健康检查,`n8n` 会等待数据库就绪后再启动
|
||||||
|
- Mac 上如果遇到 `Restarting (139)`,已在 `docker-compose.yml` 中加入 `platform: linux/amd64` 和 `user: "0:0"`
|
||||||
|
|||||||
@ -4,14 +4,14 @@ services:
|
|||||||
container_name: n8n-postgres
|
container_name: n8n-postgres
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: ${POSTGRES_USER}
|
POSTGRES_USER: n8n
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
POSTGRES_PASSWORD: n8npass
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
POSTGRES_DB: n8n
|
||||||
TZ: ${TZ}
|
TZ: Asia/Shanghai
|
||||||
volumes:
|
volumes:
|
||||||
- ./postgres-data:/var/lib/postgresql/data
|
- ./postgres-data:/var/lib/postgresql/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
test: ["CMD-SHELL", "pg_isready -U n8n -d n8n"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
@ -21,15 +21,18 @@ services:
|
|||||||
container_name: n8n
|
container_name: n8n
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "${N8N_PORT}:5678"
|
- "5678:5678"
|
||||||
|
# Mac 上如遇 `Restarting (139)` 可开启以下两项:
|
||||||
|
# platform: linux/amd64
|
||||||
|
# user: "0:0"
|
||||||
environment:
|
environment:
|
||||||
DB_TYPE: postgresdb
|
DB_TYPE: postgresdb
|
||||||
DB_POSTGRESDB_HOST: postgres
|
DB_POSTGRESDB_HOST: postgres
|
||||||
DB_POSTGRESDB_PORT: 5432
|
DB_POSTGRESDB_PORT: 5432
|
||||||
DB_POSTGRESDB_DATABASE: ${POSTGRES_DB}
|
DB_POSTGRESDB_DATABASE: n8n
|
||||||
DB_POSTGRESDB_USER: ${POSTGRES_USER}
|
DB_POSTGRESDB_USER: n8n
|
||||||
DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
|
DB_POSTGRESDB_PASSWORD: n8npass
|
||||||
TZ: ${TZ}
|
TZ: Asia/Shanghai
|
||||||
volumes:
|
volumes:
|
||||||
- ./n8n-data:/home/node/.n8n
|
- ./n8n-data:/home/node/.n8n
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
Reference in New Issue
Block a user