Axel Verne → Junk Drawer kit → Chapter 15

Chapter 15 — The Oracle III: Automations with n8n

4 blocks to copy, in the order they appear in the chapter. Nothing here is required to be typed by hand.

Step 1: Compose file for n8n

15.1 · bash
mkdir -p /srv/lab/compose/n8n && cd /srv/lab/compose/n8n
15.2 · bash
# n8n will generate a random encryption key on first launch.
# If you want to set your own (for consistency across restarts):
N8N_ENCRYPTION_KEY=your-very-random-string-min-32-chars
N8N_HOST=n8n.local
N8N_PROTOCOL=http
N8N_PORT=5678
# This is the base URL for webhooks that trigger workflows
WEBHOOK_URL=http://n8n.local:5678/
15.3 · yaml
services:
  n8n:
    image: docker.io/n8nio/n8n:latest
    container_name: n8n
    ports:
      - "5678:5678"
    environment:
      - TZ=Pacific/Honolulu
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
      - N8N_HOST=${N8N_HOST}
      - N8N_PROTOCOL=${N8N_PROTOCOL}
      - N8N_PORT=${N8N_PORT}
      - WEBHOOK_URL=${WEBHOOK_URL}
      # Optional: if using SQLite (default), this is fine.
      # To use Postgres, add:
      # - DB_TYPE=postgresdb
      # - DB_POSTGRESDB_HOST=postgres
      # - DB_POSTGRESDB_PORT=5432
      # - DB_POSTGRESDB_DATABASE=n8n
      # - DB_POSTGRESDB_USER=n8n
      # - DB_POSTGRESDB_PASSWORD=your-db-password
    volumes:
      - /srv/lab/data/n8n:/home/node/.n8n
    restart: unless-stopped
    # Optional: add postgres service below for production
15.4 · bash
docker compose up -d
docker compose logs -f  # wait for "n8n ready on 0.0.0.0:5678" then Ctrl-C

← Chapter 14Chapter 16 →

Get the next build in your inbox

An email when a new build write-up goes up: what I ran, on what hardware, and the commands that paste. Free, unsubscribe any time. The kit stays free either way.