volumes: db_storage: n8n_storage: redis_storage: x-shared: &shared restart: always image: docker.n8n.io/n8nio/n8n:${N8N_VERSION} 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_ENCRYPTION_KEY=${ENCRYPTION_KEY} - N8N_RUNNERS_MODE=external - N8N_RUNNERS_AUTH_TOKEN=${RUNNERS_AUTH_TOKEN} - N8N_RUNNERS_BROKER_LISTEN_ADDRESS=0.0.0.0 - OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS=true volumes: - n8n_storage:/home/node/.n8n depends_on: redis: condition: service_healthy postgres: condition: service_healthy x-runner: &runner restart: always image: n8nio/runners:${N8N_VERSION} environment: - N8N_RUNNERS_AUTH_TOKEN=${RUNNERS_AUTH_TOKEN} services: postgres: image: postgres:18 restart: always environment: - POSTGRES_USER - POSTGRES_PASSWORD - POSTGRES_DB - POSTGRES_NON_ROOT_USER - POSTGRES_NON_ROOT_PASSWORD # postgres:18 moved its default data dir. Pinning it keeps the volume # mount stable across major versions. - PGDATA=/var/lib/postgresql/data 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:7-alpine restart: always volumes: - redis_storage:/data healthcheck: test: ['CMD', 'redis-cli', 'ping'] interval: 5s timeout: 5s retries: 10 n8n: <<: *shared ports: - 5678:5678 n8n-runner: <<: *runner environment: - N8N_RUNNERS_AUTH_TOKEN=${RUNNERS_AUTH_TOKEN} - N8N_RUNNERS_TASK_BROKER_URI=http://n8n:5679 depends_on: - n8n n8n-worker: <<: *shared command: worker depends_on: - n8n n8n-worker-runner: <<: *runner environment: - N8N_RUNNERS_AUTH_TOKEN=${RUNNERS_AUTH_TOKEN} - N8N_RUNNERS_TASK_BROKER_URI=http://n8n-worker:5679 depends_on: - n8n-worker