n8n

n8n

Workflow automation platform

The world’s most popular workflow automation platform for technical teams

🏠 Home: https://n8n.io/
Install: https://docs.n8n.io/hosting/installation/docker/
Compose based on: https://github.com/n8n-io/n8n-hosting/blob/main/docker-compose/withPostgres/docker-compose.yml

name: n8n
services:
  n8n-postgres:
    image: postgres:16-alpine
    container_name: n8n-postgres
    networks:
      - n8n-backend
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${N8N_POSTGRES_USER}
      POSTGRES_PASSWORD: ${N8N_POSTGRES_PASSWORD}
      POSTGRES_DB: ${N8N_POSTGRES_DB}
    volumes:
      - n8n_postgres_storage:/var/lib/postgresql/data
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -h localhost -U ${N8N_POSTGRES_USER} -d ${N8N_POSTGRES_DB}']
      interval: 5s
      timeout: 5s
      retries: 10

  initContainer:
    image: busybox
    container_name: n8n-init
    command: ['sh', '-c', 'chown -R 1000:1000 /home/node/.n8n']
    volumes:
      - ${DOCKER_VOLUMES}/n8n:/home/node/.n8n

  n8n:
    image: docker.n8n.io/n8nio/n8n:1.97.1
    container_name: n8n
    restart: unless-stopped
    environment:
      TZ: ${TIMEZONE}
      GENERIC_TIMEZONE: ${TIMEZONE}
      WEBHOOK_URL: https://n8n.${MYDOMAIN}/
      N8N_HOST: n8n.${MYDOMAIN}
      N8N_PORT: 5678
      N8N_PROTOCOL: https
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
      N8N_USER_MANAGEMENT_JWT_SECRET: ${N8N_USER_MANAGEMENT_JWT_SECRET}
      DB_TYPE: postgresdb
      DB_POSTGRESDB_HOST: n8n-postgres
      DB_POSTGRESDB_USER: ${N8N_POSTGRES_USER}
      DB_POSTGRESDB_PASSWORD: ${N8N_POSTGRES_PASSWORD}
      NODE_ENV: production
    volumes:
      - ${DOCKER_VOLUMES}/n8n:/home/node/.n8n
    networks:
      - n8n-backend
      - proxy
    depends_on:
      initContainer:
        condition: service_completed_successfully
      n8n-postgres:
        condition: service_healthy
    labels:
      traefik.enable: true
      traefik.http.routers.n8n.middlewares: localaccess@file
      traefik.http.services.n8n.loadbalancer.server.port: 5678
      homepage.group: Automation
      homepage.name: n8n
      homepage.icon: n8n.png
      homepage.href: https://n8n.${MYDOMAIN}/
      homepage.description: Workflow automation platform

networks:
  n8n-backend:
    external: false
  proxy:
    external: true

volumes:
  n8n_postgres_storage: