Skip to content

Instantly share code, notes, and snippets.

@YuriFontella
Created December 3, 2025 21:54
Show Gist options
  • Select an option

  • Save YuriFontella/f1a091b4f99f35e6b0892e7c2a3bb8a4 to your computer and use it in GitHub Desktop.

Select an option

Save YuriFontella/f1a091b4f99f35e6b0892e7c2a3bb8a4 to your computer and use it in GitHub Desktop.
n8n
version: "3.8"
services:
n8n_editor:
image: n8nio/n8n:latest
command: start
networks:
- traefik-public
- backend
- redis
- n8n
environment: &common-env
N8N_ENCRYPTION_KEY: gJ308QrQUgwM2z5
N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS: "true"
NODE_ENV: production
N8N_PAYLOAD_SIZE_MAX: 16
N8N_LOG_LEVEL: error
GENERIC_TIMEZONE: America/Sao_Paulo
DB_TYPE: postgresdb
DB_POSTGRESDB_DATABASE: n8n_queue
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_PORT: 5432
DB_POSTGRESDB_USER: admin
DB_POSTGRESDB_PASSWORD: ${DB_POSTGRESDB_PASSWORD?Variable not set}
N8N_PORT: 5678
N8N_HOST: n8n.domain.com
N8N_EDITOR_BASE_URL: https://n8n.domain.com
N8N_PROTOCOL: https
WEBHOOK_URL: https://webhooks.n8n.domain.com
EXECUTIONS_MODE: queue
QUEUE_BULL_REDIS_HOST: redis
QUEUE_BULL_REDIS_PORT: 6379
QUEUE_BULL_REDIS_DB: 2
QUEUE_BULL_REDIS_PREFIX: 'n8n'
EXECUTIONS_DATA_PRUNE: "true"
EXECUTIONS_DATA_MAX_AGE: 86400
deploy: &common-deploy
mode: replicated
replicas: 1
placement:
constraints:
- node.labels.role == applications
resources:
limits:
cpus: '1'
memory: 2G
reservations:
cpus: '0.25'
memory: 512M
update_config:
parallelism: 1
delay: 30s
order: start-first
failure_action: rollback
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.routers.n8n_editor.rule=Host(`n8n.domain.com`)
- traefik.http.routers.n8n_editor.entrypoints=https
- traefik.http.routers.n8n_editor.tls=true
- traefik.http.routers.n8n_editor.tls.certresolver=le
- traefik.http.services.n8n_editor.loadbalancer.server.port=5678
n8n_worker:
image: n8nio/n8n:latest
command: worker --concurrency=10
networks:
- n8n
- backend
- redis
environment:
<<: *common-env
deploy:
<<: *common-deploy
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '0.25'
memory: 512M
labels:
- traefik.enable=false
n8n_webhook:
image: n8nio/n8n:latest
command: webhook
networks:
- traefik-public
- n8n
- backend
- redis
environment:
<<: *common-env
deploy:
<<: *common-deploy
resources:
limits:
cpus: '4'
memory: 2G
reservations:
cpus: '0.25'
memory: 512M
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.routers.n8n_webhook.rule=Host(`webhooks.n8n.domain.com`)
- traefik.http.routers.n8n_webhook.entrypoints=https
- traefik.http.routers.n8n_webhook.tls=true
- traefik.http.routers.n8n_webhook.tls.certresolver=le
- traefik.http.services.n8n_webhook.loadbalancer.server.port=5678
networks:
traefik-public:
external: true
backend:
external: true
redis:
external: true
n8n:
external: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment