mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
[N8N-4265] Improve docker compose setup with postgres (#3369)
* persist postgres data using docker volumes * persist n8n data using docker volumes instead of writing to the host filesystem * wait for postgres to be actually ready before starting the server * run web server and workers as separate containers * create a new `withPostgresAndWorker` example
This commit is contained in:
committed by
GitHub
parent
6c9486926b
commit
e53d5d9cc1
@@ -1,4 +1,8 @@
|
||||
version: '3.1'
|
||||
version: '3.8'
|
||||
|
||||
volumes:
|
||||
db_storage:
|
||||
n8n_storage:
|
||||
|
||||
services:
|
||||
|
||||
@@ -12,7 +16,13 @@ services:
|
||||
- POSTGRES_NON_ROOT_USER
|
||||
- POSTGRES_NON_ROOT_PASSWORD
|
||||
volumes:
|
||||
- db_storage:/var/lib/postgresql/data
|
||||
- ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
n8n:
|
||||
image: n8nio/n8n
|
||||
@@ -32,7 +42,8 @@ services:
|
||||
links:
|
||||
- postgres
|
||||
volumes:
|
||||
- ~/.n8n:/home/node/.n8n
|
||||
# Wait 5 seconds to start n8n to make sure that PostgreSQL is ready
|
||||
# when n8n tries to connect to it
|
||||
command: /bin/sh -c "sleep 5; n8n start"
|
||||
- n8n_storage:/home/node/
|
||||
command: /bin/sh -c "n8n start --tunnel"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
|
||||
Reference in New Issue
Block a user