services: app: image: n8nio/n8n:${N8N_APP_VERSION:-latest} container_name: n8n-app environment: - TZ=${N8N_TZ:-America/Los_Angeles} - DB_TYPE=postgresdb - DB_POSTGRESDB_HOST=n8n-db - DB_POSTGRESDB_PORT=5432 - DB_POSTGRESDB_DATABASE=n8n - DB_POSTGRESDB_USER=n8n - DB_POSTGRESDB_PASSWORD=${N8N_DB_PASSWORD:-changeme} - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY:-changeme_random_string} - WEBHOOK_URL=${N8N_URL:-https://n8n.yourdomain.com} volumes: - n8n-app:/home/node/.n8n ports: - ${N8N_PORT:-5678}:5678 depends_on: db: condition: service_healthy healthcheck: test: ["CMD-SHELL", "wget -qO- http://localhost:5678/healthz || exit 1"] interval: 30s timeout: 10s retries: 3 start_period: 30s deploy: resources: limits: memory: 512m restart: unless-stopped db: image: postgres:${N8N_DB_VERSION:-16} container_name: n8n-db environment: - POSTGRES_DB=n8n - POSTGRES_USER=n8n - POSTGRES_PASSWORD=${N8N_DB_PASSWORD:-changeme} volumes: - n8n-db:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U n8n -d n8n"] interval: 10s timeout: 5s retries: 5 start_period: 10s deploy: resources: limits: memory: 512m restart: unless-stopped volumes: n8n-app: name: n8n-app n8n-db: name: n8n-db