64 lines
1.8 KiB
YAML
64 lines
1.8 KiB
YAML
# /opt/stacks/n8n/docker-compose.yml
|
|
|
|
services:
|
|
|
|
postgres:
|
|
image: postgres:15
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_USER: '${POSTGRES_USER}'
|
|
POSTGRES_PASSWORD: '${POSTGRES_PASSWORD}'
|
|
POSTGRES_DB: '${POSTGRES_DB}'
|
|
TZ: Europe/Madrid
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck: # Crític: n8n espera que postgres estigui llest
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 30s
|
|
networks:
|
|
- n8n-net
|
|
|
|
n8n:
|
|
image: n8nio/n8n:latest
|
|
restart: unless-stopped
|
|
ports:
|
|
- "5678:5678" # Interfície web (només local → via Nginx)
|
|
environment:
|
|
TZ: Europe/Madrid
|
|
GENERIC_TIMEZONE: Europe/Madrid # Necessari per a workflows cron
|
|
# Base de dades
|
|
DB_TYPE: postgresdb
|
|
DB_POSTGRESDB_HOST: postgres
|
|
DB_POSTGRESDB_PORT: 5432
|
|
DB_POSTGRESDB_DATABASE: '${POSTGRES_DB}'
|
|
DB_POSTGRESDB_USER: '${POSTGRES_USER}'
|
|
DB_POSTGRESDB_PASSWORD: '${POSTGRES_PASSWORD}'
|
|
# Seguretat
|
|
N8N_ENCRYPTION_KEY: '${N8N_ENCRYPTION_KEY}' # CRÍTIC: mai canviar un cop configurat
|
|
# URL pública (necessari per a webhooks)
|
|
N8N_HOST: '${N8N_HOST}'
|
|
N8N_PORT: 5678
|
|
N8N_PROTOCOL: https
|
|
WEBHOOK_URL: 'https://${N8N_HOST}/'
|
|
volumes:
|
|
- n8n_data:/home/node/.n8n
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy # Espera que postgres estigui realment llest
|
|
networks:
|
|
- n8n-net
|
|
- shared_net
|
|
|
|
volumes:
|
|
postgres_data:
|
|
n8n_data:
|
|
|
|
networks:
|
|
n8n-net:
|
|
driver: bridge
|
|
shared_net:
|
|
external: true
|
|
name: shared_net |