Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sagararyal committed Nov 1, 2023
1 parent a76736f commit 5df678b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 211 deletions.
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
20 changes: 2 additions & 18 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,17 @@
"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"
},
"NODE_TLS_REJECT_UNAUTHORIZED": {
"description": "Because Heroku SSL is self signed, SSL fails if this is not set to 0",
"value": 0
"value": "no-verify"
},
"WEBHOOK_URL": {
"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 ",
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
53 changes: 7 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 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

0 comments on commit 5df678b

Please sign in to comment.