Files
Docker-Compose/n8n/docker-compose.yml
2026-02-12 01:24:59 +08:00

206 lines
6.9 KiB
YAML

version: "3.7"
services:
main:
image: ${N8N_IMAGE}
command: start
restart: unless-stopped
user: ${N8N_UID}
networks:
- traefik_proxy
- default
ports:
- "5678:5678"
environment:
# Database
- DB_TYPE=postgresdb
- DB_POSTGRESDB_DATABASE=${N8N_POSTGRESDB_DATABASE}
- DB_POSTGRESDB_HOST=db
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_USER=${N8N_POSTGRESDB_USER}
- DB_POSTGRESDB_PASSWORD=${N8N_POSTGRESDB_PASSWORD}
# Redis
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_BULL_REDIS_PORT=6379
- QUEUE_BULL_REDIS_DB=0
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
- N8N_HOST=${N8N_HOST}
- N8N_PORT=5678
- N8N_EDITOR_BASE_URL=${N8N_EDITOR_URL}
- N8N_PROTOCOL=https
- NODE_ENV=production
- N8N_LOG_LEVEL=debug
- WEBHOOK_URL=${N8N_WEBHOOK_URL}
- EXECUTIONS_MODE=queue
- N8N_DISABLE_PRODUCTION_MAIN_PROCESS=true
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- NODE_FUNCTION_ALLOW_EXTERNAL=${NODE_FUNCTION_ALLOW_EXTERNAL}
#- NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=168
- GENERIC_TIMEZONE=${N8N_TZ}
- TZ=${N8N_TZ}
volumes:
- /mnt:/mnt
deploy:
mode: replicated
replicas: 1
labels:
- homepage.group=Management
- homepage.name=n8n
- homepage.icon=sh-n8n-light
- homepage.href=${N8N_EDITOR_URL}
- homepage.description=n8n is a workflow automation platform that gives technical teams the flexibility of code with the speed of no-code.
- homepage.widgets[0].type=customapi
- homepage.widgets[0].url=http://cluster.localdomain:5679/webhook/bbf20adf-170b-4b4e-90fb-eea4ce74a3df
- homepage.widgets[0].refreshInterval=10000 # optional - in milliseconds, defaults to 10s
#- homepage.widgets[0].username: username # auth - optional
#- homepage.widgets[0].password: password # auth - optional
#- homepage.widgets[0].method: GET # optional, e.g. POST
#- homepage.widgets[0].headers: # optional, must be object, see below
#- homepage.widgets[0].requestBody: # optional, can be string or object, see below
#- homepage.widgets[0].display=list # optional, default to block, see below
- homepage.widgets[0].mappings[0].field[0]=workflows
- homepage.widgets[0].mappings[0].label=Workflows
- homepage.widgets[0].mappings[0].format=text
#- homepage.widgets[0].mappings[0].additionalField.field.data.status=state
#- homepage.widgets[0].mappings[0].additionalField.color=theme
#- homepage.widgets[0].mappings[0].additionalField.format=text
- homepage.widgets[0].mappings[1].field[1]=executions
- homepage.widgets[0].mappings[1].label=Executions
- homepage.widgets[0].mappings[1].format=text
- homepage.widgets[0].mappings[2].field[1]=failedExecutions
- homepage.widgets[0].mappings[2].label=Failed
- homepage.widgets[0].mappings[2].format=text
- "traefik.enable=true"
- "traefik.http.routers.n8n.rule=Host(`n8n.dua.casa`)"
- "traefik.http.routers.n8n.entrypoints=websecure"
- "traefik.http.routers.n8n.tls=true"
- "traefik.http.routers.n8n.tls.certresolver=letsencrypt"
- "traefik.http.routers.n8n.service=n8n-service"
- "traefik.http.services.n8n-service.loadbalancer.server.port=5678"
worker:
image: ${N8N_IMAGE}
command: worker --concurrency=10
restart: unless-stopped
user: ${N8N_UID}
environment:
# Database
- DB_TYPE=postgresdb
- DB_POSTGRESDB_DATABASE=${N8N_POSTGRESDB_DATABASE}
- DB_POSTGRESDB_HOST=db
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_USER=${N8N_POSTGRESDB_USER}
- DB_POSTGRESDB_PASSWORD=${N8N_POSTGRESDB_PASSWORD}
# Redis
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_BULL_REDIS_PORT=6379
- QUEUE_BULL_REDIS_DB=0
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
- N8N_HOST=${N8N_HOST}
- N8N_PORT=5678
- N8N_EDITOR_BASE_URL=${N8N_EDITOR_URL}
- N8N_PROTOCOL=https
- NODE_ENV=production
- N8N_LOG_LEVEL=debug
- WEBHOOK_URL=${N8N_WEBHOOK_URL}
- EXECUTIONS_MODE=queue
- N8N_DISABLE_PRODUCTION_MAIN_PROCESS=true
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- NODE_FUNCTION_ALLOW_EXTERNAL=${NODE_FUNCTION_ALLOW_EXTERNAL}
#- NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=168
- GENERIC_TIMEZONE=${N8N_TZ}
- TZ=${N8N_TZ}
volumes:
- /mnt:/mnt
deploy:
mode: global
webhook:
image: ${N8N_IMAGE}
command: webhook
restart: unless-stopped
user: ${N8N_UID}
networks:
- traefik_proxy
- default
ports:
- "5679:5678"
environment:
# Database
- DB_TYPE=postgresdb
- DB_POSTGRESDB_DATABASE=${N8N_POSTGRESDB_DATABASE}
- DB_POSTGRESDB_HOST=db
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_USER=${N8N_POSTGRESDB_USER}
- DB_POSTGRESDB_PASSWORD=${N8N_POSTGRESDB_PASSWORD}
# Redis
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_BULL_REDIS_PORT=6379
- QUEUE_BULL_REDIS_DB=0
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
- N8N_HOST=${N8N_HOST}
- N8N_PORT=5678
- N8N_EDITOR_BASE_URL=${N8N_EDITOR_URL}
- N8N_PROTOCOL=https
- NODE_ENV=production
- N8N_LOG_LEVEL=debug
- WEBHOOK_URL=${N8N_WEBHOOK_URL}
- EXECUTIONS_MODE=queue
- N8N_DISABLE_PRODUCTION_MAIN_PROCESS=true
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- NODE_FUNCTION_ALLOW_EXTERNAL=${NODE_FUNCTION_ALLOW_EXTERNAL}
#- NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=168
- GENERIC_TIMEZONE=${N8N_TZ}
- TZ=${N8N_TZ}
volumes:
- /mnt:/mnt
deploy:
mode: replicated
replicas: 1
labels:
- "traefik.enable=true"
- "traefik.http.routers.n8nwebhook.rule=Host(`n8n-webhook.dua.casa`)"
- "traefik.http.routers.n8nwebhook.entrypoints=websecure"
- "traefik.http.routers.n8nwebhook.tls=true"
- "traefik.http.routers.n8nwebhook.tls.certresolver=letsencrypt"
- "traefik.http.routers.n8nwebhook.service=n8nwebhook-service"
- "traefik.http.services.n8nwebhook-service.loadbalancer.server.port=5678"
redis:
image: redis:alpine
restart: unless-stopped
user: ${N8N_UID}
db:
image: postgres:16
restart: unless-stopped
user: ${N8N_UID}
volumes:
- /mnt/docker-storage/n8n:/var/lib/postgresql/data
environment:
- TZ=${N8N_TZ}
- POSTGRES_DB=${N8N_POSTGRESDB_DATABASE}
- POSTGRES_USER=${N8N_POSTGRESDB_USER}
- POSTGRES_PASSWORD=${N8N_POSTGRESDB_PASSWORD}
networks:
traefik_proxy:
external: true