n8n Automation
A self-hosted n8n automation stack with PostgreSQL 16 as the persistence layer for workflows, credentials, and execution history. n8n is configured with basic authentication and exposes its web editor on port 5678, while PostgreSQL stores all data in a named volume for durability. The stack supports webhook URLs, timezone configuration, and execution pruning out of the box. Both services run on an internal backend network with health checks and resource limits to ensure stable long-running operation. Simply set the environment variables and access the n8n editor to start building automation workflows.
Enthaltene Services
n8n
n8nio/n8n:latest
Umgebungsvariablen:
postgres
postgres:16-alpine
Umgebungsvariablen:
Generiertes YAML
# Generated by ComposeHub (composehub.dev)
name: n8n-automation
services:
n8n:
image: n8nio/n8n:latest
restart: unless-stopped
ports:
- 5678:5678
volumes:
- n8n_data:/home/node/.n8n
environment:
N8N_BASIC_AUTH_ACTIVE: ${N8N_BASIC_AUTH_ACTIVE:-true}
N8N_BASIC_AUTH_USER: ${N8N_BASIC_AUTH_USER:-admin}
N8N_BASIC_AUTH_PASSWORD: ${N8N_BASIC_AUTH_PASSWORD:-changeme}
N8N_HOST: ${N8N_HOST:-localhost}
N8N_PORT: "5678"
N8N_PROTOCOL: ${N8N_PROTOCOL:-http}
WEBHOOK_URL: ${WEBHOOK_URL:-http://localhost:5678/}
GENERIC_TIMEZONE: ${GENERIC_TIMEZONE:-UTC}
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_PORT: "5432"
DB_POSTGRESDB_DATABASE: ${POSTGRES_DB:-n8n}
DB_POSTGRESDB_USER: ${POSTGRES_USER:-n8n}
DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
EXECUTIONS_DATA_PRUNE: ${EXECUTIONS_DATA_PRUNE:-true}
EXECUTIONS_DATA_MAX_AGE: ${EXECUTIONS_DATA_MAX_AGE:-168}
N8N_METRICS: ${N8N_METRICS:-true}
networks:
- backend
depends_on:
postgres:
condition: service_healthy
healthcheck:
test:
- CMD-SHELL
- wget --no-verbose --tries=1 --spider http://localhost:5678/healthz || exit 1
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: "2.00"
memory: 1024M
reservations:
cpus: "0.50"
memory: 256M
labels:
com.composeforge.description: n8n workflow automation engine
postgres:
image: postgres:16-alpine
restart: unless-stopped
command:
- postgres
- "-c"
- shared_buffers=128MB
- "-c"
- effective_cache_size=384MB
- "-c"
- work_mem=8MB
- "-c"
- max_connections=50
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${POSTGRES_DB:-n8n}
POSTGRES_USER: ${POSTGRES_USER:-n8n}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
networks:
- backend
healthcheck:
test:
- CMD-SHELL
- pg_isready -U ${POSTGRES_USER:-n8n} -d ${POSTGRES_DB:-n8n}
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: "1.00"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
labels:
com.composeforge.description: PostgreSQL 16 database for n8n workflow storage
networks:
backend:
driver: bridge
volumes:
n8n_data:
driver: local
postgres_data:
driver: local
Kurzinfo
- Services
- 2
- Netzwerke
- 1
- Volumes
- 2
Wann verwenden
Dieses Template ist ideal für die Einrichtung einer n8n automation Umgebung. Alle Services sind mit Healthchecks, Ressourcenlimits und sinnvollen Standardwerten vorkonfiguriert. Passen Sie die Umgebungsvariablen an, bevor Sie in Produktion gehen.
Tipps
- Ändern Sie alle Standardpasswörter vor dem Deployment
- Überprüfen Sie die Ressourcenlimits für Ihre Hardware
- Fügen Sie einen Reverse Proxy für HTTPS in Produktion hinzu
- Konfigurieren Sie Backup-Strategien für Daten-Volumes