Skip to content

Instantly share code, notes, and snippets.

@diegofcornejo
Last active April 30, 2025 18:21
Show Gist options
  • Save diegofcornejo/f3634bb19285140b59f417c49ef3f9bd to your computer and use it in GitHub Desktop.
Save diegofcornejo/f3634bb19285140b59f417c49ef3f9bd to your computer and use it in GitHub Desktop.
N8N Docker
name: n8n
volumes:
db_storage:
n8n_storage:
services:
postgres:
image: postgres:16.6
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
n8n:
image: docker.n8n.io/n8nio/n8n
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}
- N8N_EDITOR_BASE_URL
- N8N_METRICS
- WEBHOOK_URL
- TZ
- GENERIC_TIMEZONE
- N8N_SMTP_HOST
- N8N_SMTP_PORT
- N8N_SMTP_USER
- N8N_SMTP_PASS
- N8N_SMTP_SENDER
- N8N_SMTP_SSL
- N8N_RUNNERS_ENABLED
ports:
- 5678:5678
links:
- postgres
volumes:
- n8n_storage:/home/node/.n8n
- ./shared:/data/shared
depends_on:
postgres:
condition: service_healthy
# DATABASE
POSTGRES_USER=n8ndbadmin
POSTGRES_PASSWORD=changepassword
POSTGRES_DB=n8n
POSTGRES_NON_ROOT_USER=n8ndbuser
POSTGRES_NON_ROOT_PASSWORD=changepassword
# DEPLOYMENT
N8N_EDITOR_BASE_URL=https://n8n.yourdomain.com
N8N_METRICS=true
WEBHOOK_URL=https://n8n.yourdomain.com/
N8N_RUNNERS_ENABLED=true
# TIMEZONE
TZ=America/Guatemala
GENERIC_TIMEZONE=America/Guatemala
# MAIL
N8N_SMTP_HOST=email-smtp.us-east-1.amazonaws.com
N8N_SMTP_PORT=587
N8N_SMTP_USER=<AWS_ACCESS_KEY_ID>
N8N_SMTP_PASS=<AWS_SECRET_ACCESS_KEY>
N8N_SMTP_SENDER="N8N <[email protected]>"
N8N_SMTP_SSL=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment