mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
e53d5d9cc1
* 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
78 lines
1.7 KiB
YAML
78 lines
1.7 KiB
YAML
version: '3.8'
|
|
|
|
volumes:
|
|
db_storage:
|
|
n8n_storage:
|
|
redis_storage:
|
|
|
|
x-shared: &shared
|
|
restart: always
|
|
environment:
|
|
- DB_TYPE=postgresdb
|
|
- DB_POSTGRESDB_HOST=postgres
|
|
- DB_POSTGRESDB_PORT=5432
|
|
- DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
|
|
- DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
|
|
- DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
|
|
- EXECUTIONS_MODE=queue
|
|
- QUEUE_BULL_REDIS_HOST=redis
|
|
- QUEUE_HEALTH_CHECK_ACTIVE=true
|
|
- N8N_BASIC_AUTH_ACTIVE=true
|
|
- N8N_BASIC_AUTH_USER
|
|
- N8N_BASIC_AUTH_PASSWORD
|
|
links:
|
|
- postgres
|
|
- redis
|
|
volumes:
|
|
- n8n_storage:/home/node/
|
|
depends_on:
|
|
redis:
|
|
condition: service_healthy
|
|
postgres:
|
|
condition: service_healthy
|
|
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:11
|
|
restart: always
|
|
environment:
|
|
- POSTGRES_USER
|
|
- POSTGRES_PASSWORD
|
|
- POSTGRES_DB
|
|
- 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
|
|
|
|
redis:
|
|
image: redis:6-alpine
|
|
restart: always
|
|
volumes:
|
|
- redis_storage:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 10
|
|
|
|
n8n:
|
|
<<: *shared
|
|
image: n8nio/n8n
|
|
command: /bin/sh -c "n8n start --tunnel"
|
|
ports:
|
|
- 5678:5678
|
|
|
|
n8n-worker:
|
|
<<: *shared
|
|
image: n8nio/n8n
|
|
command: /bin/sh -c "sleep 5; n8n worker"
|
|
depends_on:
|
|
- n8n
|