Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs #67

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
FROM node:lts-alpine
FROM n8nio/n8n:latest

# pass N8N_VERSION Argument while building or use default

ARG N8N_VERSION=1.9.3

# Update everything and install needed dependencies
RUN apk add --update graphicsmagick tzdata

# Set a custom user to not have n8n run as root
USER root

# Install n8n and the also temporary all the packages
# it needs to build it correctly.
RUN apk --update add --virtual build-dependencies python3 build-base git && \
npm_config_user=root npm install --location=global n8n@${N8N_VERSION} && \
apk del build-dependencies
RUN cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-document-generator
RUN cd /usr/local/lib/node_modules/n8n && npm install @google/earthengine && npm install -g @turf/turf

# Specifying work directory
WORKDIR /data
WORKDIR /home/node/packages/cli
ENTRYPOINT []

# copy start script to container
COPY ./start.sh /
Expand Down
102 changes: 4 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,112 +6,18 @@

#### [ Open Source Contributors feel free to maintain this repository ]

New method, just click, configure and get your n8n running.
Also, now set app stack to container and simply connect this Github repo and deploy, heroku uses default configuration from app.json
A new method, just click, configure, and get your n8n running.
Also, now set the app stack to container and simply connect this Github repo and deploy, Heroku uses default configuration from app.json

default basic auth is user:pass
This deployment supports queue mode with Heroku worker and Redis for scaleability.

### n8n(Nodemation) - Free and Open Workflow Automation Tool

This is a [Heroku](https://heroku.com/) focused container implementation for the [n8n Automation Tool](https://n8n.io/). Just connect your fork to heroku and let it work as a charm!
This is a [Heroku](https://heroku.com/) focused container implementation for the [n8n Automation Tool](https://n8n.io/). Just connect your fork to Heroku and let it work as a charm!

## Requirements
* Heroku CLI

## Setup

this is old setup guide not required now, connect this GitHub repo to heroku to autoconfigure. or click the above button to deploy without GitHub.

### STEP 1: CHANGE your App Stack to container
you can change your app's stack using heroku cli, make sure you have heroku cli installed.

#### login into heroku account
heroku login

#### change app stack
heroku stack:set contaner --app APP_NAME
replace APP_NAME with your heroku app name

### STEP 2: ADD Config Vars for enabling basic authentication (Optional)
It's recommended that you enable basic authentication when deployingn n8n on web. You need to set the following Environment Variables(Config Vars) in your App settings.

N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=SET_USERNAME
N8N_BASIC_AUTH_PASSWORD=SET_PASSWORD

Using filesystem/sqlite as storage will destroy any workflows on new builds/releases it it recommended to use mongodb or postgreSQL as the drivers are built into the code.

DB_TYPE=mongodb
DB_MONGODB_CONNECTION_URL=mongodb://MONGODB_USERNAME:MONGODB_PASSWORD@HOST:PORT/MONGODB_DATABASE

you will get the connection string in the heroku mongodb addon or any service you choose. using heroku addons is recommended as they auto configure ENV Variables for you. just copy MONGODB_URI to DB_MONGODB_CONNECTION_URL. that's it.

Same process is to be followed for using postgreSQL.

DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=POSTGRES_HOST
DB_POSTGRESDB_PORT=POSTGRES_PORT
DB_POSTGRESDB_DATABASE=POSTGRES_DB
DB_POSTGRESDB_USER=POSTGRES_USER
DB_POSTGRESDB_PASSWORD=POSTGRES_PASSWORD

If some of your triggers depend on published app domain you may need to explicitly set url for yours n8n instance

WEBHOOK_URL=https://your-app.herokuapp.com


### STEP 3: DONE! Now CONNECT GitHub repo and Deploy.

## Using Container Registry

you can also deploy this project using container registry (requires aditional requirements installed). Just clone/download this repository on your local machine.

### Additional Requirements (for building on local)
* docker
* docker-compose

### Steps
cd into your project directory

cd n8n-heroku/

login into heroku account

heroku login

create heroku app

heroku create APP_NAME

change app stack

heroku stack:set container --app APP_NAME

set config vars(optional)

heroku config:set N8N_BASIC_AUTH_ACTIVE=true
heroku config:set N8N_BASIC_AUTH_USER=SET_USERNAME
heroku config:set N8N_BASIC_AUTH_PASSWORD=SET_PASSWORD

Login the container

heroku container:login

build and push container image to heroku

heroku container:push web --app APP_NAME

release new build

heroku container:release web --app APP_NAME

<br />

Maybe now you can specify which N8N version to install by Setting a Environment Variable N8N_VERSION or with a build time argument of the same. Not tested yet though, create an issue if it does't work. CI is passing so it is working correctly with default values.

_Update - To set n8n version you can pass a argument when deploying using container registry_

heroku container:push web --arg N8N_VERSION=0.60.0 --app APP_NAME

### Sources

Expand Down
32 changes: 14 additions & 18 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,36 @@
"success_url": "/",
"stack": "container",
"env": {
"N8N_BASIC_AUTH_ACTIVE": {
"description": "Protect n8n setup with basic authentication.",
"value": "true"
},
"GENERIC_TIMEZONE": {
"description": "Time Zone to use with Heroku. You can find the name of your timezone here: https://momentjs.com/timezone/",
"value": "Europe/Berlin"
},
"N8N_BASIC_AUTH_USER": {
"description": "Basic Authentication User for n8n",
"value": "user"
},
"N8N_BASIC_AUTH_PASSWORD": {
"description": "Basic Authentication Password to secure n8n.",
"value": "pass"
},
"N8N_ENCRYPTION_KEY": {
"description": "This is to set the n8n encryption key to a static value, so that heroku doesnt override it, causing AUTH to fail",
"value": "MdRRn2jiZuVeh5tI77A6"
"value": "change-me-to-something-else"
},
"PGSSLMODE": {
"description": "Heroku made a change so SSL is required to connect to Postgres",
"value": "require"
"value": "no-verify"
},
"DB_POSTGRESDB_SSL_ENABLED": {
"description": "Introduced since [email protected] to connect to Postgres with SSL.",
"value": "true"
},
"NODE_TLS_REJECT_UNAUTHORIZED": {
"description": "Because Heroku SSL is self signed, SSL fails if this is not set to 0",
"value": 0
"description": "Heroku SSL is self signed, SSL fails if this is not set to 0",
"value": "0"
},
"WEBHOOK_URL": {
"WEBHOOK_URLQUEUE_BULL_REDIS_TLS": {
"description": "Your app could be published to any domain, without specifying n8n will think that it's hosted on localhost (and it could break some scenarions ",
"value": "https://<appname>.herokuapp.com"
},
"QUEUE_BULL_REDIS_TLS": {
"description": "Heroku is enforcing TLS on all redis mini plans starting December 2024.",
"value": "true"
},
"EXECUTIONS_MODE": {
"description": "This is to set the n8n executions mode to queue mode, recommended to be used with Postgres or MySQL",
"description": "Supports: regular, queue. Queue Mode enables Worker Dyno to process events. If you do not plan on using worker dyno, set worker dyno count to 0 and set execution mode it to regular.",
"value": "queue"
}
},
Expand Down
5 changes: 0 additions & 5 deletions heroku.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ setup:
- plan: heroku-redis
as: REDIS

config:
N8N_BASIC_AUTH_ACTIVE: true
N8N_BASIC_AUTH_USER: user
N8N_BASIC_AUTH_PASSWORD: pass

build:
docker:
web: Dockerfile
Expand Down
59 changes: 13 additions & 46 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,19 @@ parse_url() {
eval $(echo "$1" | sed -e "s#^\(\(.*\)://\)\?\(\([^:@]*\)\(:\(.*\)\)\?@\)\?\([^/?]*\)\(/\(.*\)\)\?#${PREFIX:-URL_}SCHEME='\2' ${PREFIX:-URL_}USER='\4' ${PREFIX:-URL_}PASSWORD='\6' ${PREFIX:-URL_}HOSTPORT='\7' ${PREFIX:-URL_}DATABASE='\9'#")
}

# received url as argument
ARG_URL=${1:-""}

# override if config vars detected
if [ "$DATABASE_URL" ]
then
ARG_URL=$DATABASE_URL
echo $DATABASE_URL;
echo "postgres config detected"

elif [ "$MONGODB_URI" ]
then
ARG_URL=$MONGODB_URI
echo "mongo config detected"

else
echo "no config vars found"
fi

# disable diagnostics
export N8N_DIAGNOSTICS_ENABLED=false

# prefix variables to avoid conflicts and run parse url function on arg url
PREFIX="N8N_DB_" parse_url "$ARG_URL"

PREFIX="N8N_DB_" parse_url "$DATABASE_URL"
echo "$N8N_DB_SCHEME://$N8N_DB_USER:$N8N_DB_PASSWORD@$N8N_DB_HOSTPORT/$N8N_DB_DATABASE"

# Separate host and port
N8N_DB_HOST="$(echo $N8N_DB_HOSTPORT | sed -e 's,:.*,,g')"

N8N_DB_PORT="$(echo $N8N_DB_HOSTPORT | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"

# DB switch
if [ $N8N_DB_SCHEME == 'postgres' ]
then
echo "indentified DB in use postgreSQL"
export DB_TYPE=postgresdb
export DB_POSTGRESDB_HOST=$N8N_DB_HOST
export DB_POSTGRESDB_PORT=$N8N_DB_PORT
export DB_POSTGRESDB_DATABASE=$N8N_DB_DATABASE
export DB_POSTGRESDB_USER=$N8N_DB_USER
export DB_POSTGRESDB_PASSWORD=$N8N_DB_PASSWORD

elif [ $N8N_DB_SCHEME == 'mongodb' ]
then
echo "indentified DB in use mongoDB"
export DB_TYPE=mongodb
export DB_MONGODB_CONNECTION_URL=$ARG_URL

else
echo "invalid url arg"
fi
export DB_TYPE=postgresdb
export DB_POSTGRESDB_HOST=$N8N_DB_HOST
export DB_POSTGRESDB_PORT=$N8N_DB_PORT
export DB_POSTGRESDB_DATABASE=$N8N_DB_DATABASE
export DB_POSTGRESDB_USER=$N8N_DB_USER
export DB_POSTGRESDB_PASSWORD=$N8N_DB_PASSWORD

# parse REDIS_URL if present
if [ "$REDIS_URL" ]
Expand All @@ -72,6 +33,12 @@ then
export QUEUE_BULL_REDIS_HOST=$N8N_REDIS_HOST
export QUEUE_BULL_REDIS_PORT=$N8N_REDIS_PORT
export QUEUE_BULL_REDIS_PASSWORD=$N8N_REDIS_PASSWORD

# Check if URL starts with rediss://
if [ "${N8N_REDIS_SCHEME}" = "rediss" ]; then
export QUEUE_BULL_REDIS_TLS=true
echo "Redis connection over TLS detected, setting QUEUE_BULL_REDIS_TLS=true"
fi
fi

# kickstart nodemation
Expand Down
21 changes: 5 additions & 16 deletions worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
FROM node:lts-alpine
FROM n8nio/n8n:latest

# pass N8N_VERSION Argument while building or use default

ARG N8N_VERSION=1.9.3

# Update everything and install needed dependencies
RUN apk add --update graphicsmagick tzdata

# Set a custom user to not have n8n run as root
USER root

# Install n8n and the also temporary all the packages
# it needs to build it correctly.
RUN apk --update add --virtual build-dependencies python3 build-base git && \
npm_config_user=root npm install --location=global n8n@${N8N_VERSION} && \
apk del build-dependencies
RUN cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-document-generator
RUN cd /usr/local/lib/node_modules/n8n && npm install @google/earthengine && npm install -g @turf/turf

# Specifying work directory
WORKDIR /data
WORKDIR /home/node/packages/cli
ENTRYPOINT []

# copy start script to container
COPY ./start.sh /
Expand Down
52 changes: 8 additions & 44 deletions worker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,19 @@ parse_url() {
eval $(echo "$1" | sed -e "s#^\(\(.*\)://\)\?\(\([^:@]*\)\(:\(.*\)\)\?@\)\?\([^/?]*\)\(/\(.*\)\)\?#${PREFIX:-URL_}SCHEME='\2' ${PREFIX:-URL_}USER='\4' ${PREFIX:-URL_}PASSWORD='\6' ${PREFIX:-URL_}HOSTPORT='\7' ${PREFIX:-URL_}DATABASE='\9'#")
}

# received url as argument
ARG_URL=${1:-""}

# override if config vars detected
if [ "$DATABASE_URL" ]
then
ARG_URL=$DATABASE_URL
echo "postgres config detected"

elif [ "$MONGODB_URI" ]
then
ARG_URL=$MONGODB_URI
echo "mongo config detected"

else
echo "no config vars found"
fi

# disable diagnostics
export N8N_DIAGNOSTICS_ENABLED=false

# prefix variables to avoid conflicts and run parse url function on arg url
PREFIX="N8N_DB_" parse_url "$ARG_URL"

PREFIX="N8N_DB_" parse_url "$DATABASE_URL"
echo "$N8N_DB_SCHEME://$N8N_DB_USER:$N8N_DB_PASSWORD@$N8N_DB_HOSTPORT/$N8N_DB_DATABASE"
# Separate host and port
N8N_DB_HOST="$(echo $N8N_DB_HOSTPORT | sed -e 's,:.*,,g')"

N8N_DB_PORT="$(echo $N8N_DB_HOSTPORT | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"

# DB switch
if [ $N8N_DB_SCHEME == 'postgres' ]
then
echo "indentified DB in use postgreSQL"
export DB_TYPE=postgresdb
export DB_POSTGRESDB_HOST=$N8N_DB_HOST
export DB_POSTGRESDB_PORT=$N8N_DB_PORT
export DB_POSTGRESDB_DATABASE=$N8N_DB_DATABASE
export DB_POSTGRESDB_USER=$N8N_DB_USER
export DB_POSTGRESDB_PASSWORD=$N8N_DB_PASSWORD

elif [ $N8N_DB_SCHEME == 'mongodb' ]
then
echo "indentified DB in use mongoDB"
export DB_TYPE=mongodb
export DB_MONGODB_CONNECTION_URL=$ARG_URL

else
echo "invalid url arg"
fi
export DB_TYPE=postgresdb
export DB_POSTGRESDB_HOST=$N8N_DB_HOST
export DB_POSTGRESDB_PORT=$N8N_DB_PORT
export DB_POSTGRESDB_DATABASE=$N8N_DB_DATABASE
export DB_POSTGRESDB_USER=$N8N_DB_USER
export DB_POSTGRESDB_PASSWORD=$N8N_DB_PASSWORD

# parse REDIS_URL if present
if [ "$REDIS_URL" ]
Expand Down
Loading