A skeleton for getting started with a self-hosted n8n environment running in Docker Compose.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rob Colbert 5d70a09b1c 1.0.1 2 months ago
docker-caddy import docker setup from n8n-io/n8n-docker-caddy 1 year ago
docker-compose removed version attribute from docker-compose.yml because it's deprecated 2 months ago
kubernetes import kubernetes setup from n8n-io/kubernetes-hosting 1 year ago
.gitignore configuring git and adding Node deps 2 months ago
README.md doc updates 2 months ago
package.json 1.0.1 2 months ago
pnpm-lock.yaml lock file 2 months ago

README.md

n8n-hosting

This is a fork of the bare-bones n8n-hosting GitHub project, and is a skeleton for building a Docker Compose environment for self-hosting an n8n instance in your environment to support the editor UI and worker nodes that run your jobs.

The configuration has been specialized to expose internal Node modules, external NPM modules, and our custom code, to a running n8n environment.

Our requirement for external modules and custom code in our workflows is what requires us (and you) to self-host n8n, and run it within your own environment. Their cloud hosting does not permit external modules or custom modules. We provide both.

A DTP Newsroom environment makes use of the withPostgres root environment, and has specialized it in-place in this repo. We ignore every other directory for now. We will specialize withPostgresAndWorker

Our Changes

  1. Use pnpm to manage Node packages
  2. Alter runtime environment for n8n to specify DTP webhook URL
  3. Alter runtime environment to allow external Node modules

Getting Started

Configuration

  1. Clone dtp-n8n-hosting to a directory on your host/server.

And feel free to fork it. We are pulling updates from our upstream, and you can pull updates directly from them, or from us.

  1. Run pnpm install from the root of the project.

This will create your node_modules directory to receive external modules needed by DTP Newsroom.

  1. Customize .env
cd docker-compose/withPostgres
cp .env.example .env

You'll want to customize the values specified to match your requirements in your environment. This setup will run a PostgreSQL instance in a container, link it with n8n, and n8n will directly access it using these credentials.

You define the credentials. And you don't save them in .env.sample and check them into git. That's a security antipattern. You save your credentials in .env, and git ignores that file.

POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_DB=n8n

POSTGRES_NON_ROOT_USER=
POSTGRES_NON_ROOT_PASSWORD=
  1. Customize docker-compose.yml
environment:
  - WEBHOOK_URL=https://n8n.digitaltelepresence.com/
  - NODE_FUNCTION_ALLOW_BUILTIN=*
  - NODE_FUNCTION_ALLOW_EXTERNAL=dayjs,numeral
volumes:
  - /home/dtp/live/dtp-n8n-hosting/node_modules/dayjs:/usr/local/lib/node_modules/dayjs
  - /home/dtp/live/dtp-n8n-hosting/node_modules/numeral:/usr/local/lib/node_modules/numeral

Process Management

pnpm start start the n8n environment

pnpm stop stop the n8n environment

pnpm restart restart the n8n environment

pnpm stats display streaming stats for the n8n environment Docker containers