From 72626735ca0d15219865dfe13dd2c8ae996fbcfd Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Mon, 22 Sep 2025 17:41:31 -0500 Subject: [PATCH 01/25] Update PostgreSQL version to 15 in app.json --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index 8218f22f19..da698f67bf 100644 --- a/app.json +++ b/app.json @@ -33,7 +33,7 @@ { "plan": "heroku-postgresql", "options": { - "version": "14" + "version": "15" } }, { From 800551777d11367647432c4463a6c9d2f3f47d60 Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Mon, 22 Sep 2025 17:46:22 -0500 Subject: [PATCH 02/25] Update repository URL in app.json --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index da698f67bf..c2822a5897 100644 --- a/app.json +++ b/app.json @@ -7,7 +7,7 @@ "automation" ], "website": "https://n8n.io", - "repository": "https://github.com/n8n-io/n8n-heroku", + "repository": "https://github.com/kuromi04/n8n-heroku.git", "logo": "https://raw.githubusercontent.com/n8n-io/n8n-heroku/main/n8n_logo.png", "success_url": "/", "stack": "container", From e1cd4e037c41aa3248bdcdbd695e641ab747221f Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Thu, 25 Sep 2025 21:45:39 -0500 Subject: [PATCH 03/25] Update Heroku deploy button link in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a88c2faf4a..3ad4aa4963 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # n8n-heroku -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https://github.com/n8n-io/n8n-heroku/tree/main) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=[https://github.com/kuromi04/n8n-heroku2025.git) ## n8n - Free and open fair-code licensed node based Workflow Automation Tool. From 7a90229b4430c5952b128bc9e1752aa443cc9abb Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Thu, 25 Sep 2025 21:48:09 -0500 Subject: [PATCH 04/25] Fix deploy button link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ad4aa4963..2d0cb7c2c3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # n8n-heroku -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=[https://github.com/kuromi04/n8n-heroku2025.git) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https://github.com/kuromi04/n8n-heroku2025.git) ## n8n - Free and open fair-code licensed node based Workflow Automation Tool. From a1007916846fe78c3c1f59f2b795f93e0ab8366c Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 27 Sep 2025 13:45:29 -0500 Subject: [PATCH 05/25] Update repository URL in app.json --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index c2822a5897..d6d9c6f14a 100644 --- a/app.json +++ b/app.json @@ -7,7 +7,7 @@ "automation" ], "website": "https://n8n.io", - "repository": "https://github.com/kuromi04/n8n-heroku.git", + "repository": "https://github.com/kuromi04/n8n-heroku2025.git", "logo": "https://raw.githubusercontent.com/n8n-io/n8n-heroku/main/n8n_logo.png", "success_url": "/", "stack": "container", From f43879c2a4c985b5a8f35c219ebc05001e6a7098 Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sun, 12 Oct 2025 23:57:55 -0500 Subject: [PATCH 06/25] Improve Heroku deployment for automatic n8n updates --- Dockerfile | 17 ++++-- README.md | 12 +++- app.json | 88 ++++++++++++++++------------- entrypoint.sh | 151 +++++++++++++++++++++++++++++++++++++++++++------- heroku.yml | 16 ++++-- 5 files changed, 211 insertions(+), 73 deletions(-) diff --git a/Dockerfile b/Dockerfile index 299908ebec..45b4cbe734 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,15 @@ -FROM n8nio/n8n:latest +# syntax=docker/dockerfile:1 +ARG N8N_VERSION=latest +FROM n8nio/n8n:${N8N_VERSION} + +# Run as root to allow runtime updates of the n8n CLI when requested. USER root -WORKDIR /home/node/packages/cli -ENTRYPOINT [] +# Replace the entrypoint with a Heroku-friendly bootstrap script that +# prepares the database configuration and optionally keeps n8n updated. +COPY entrypoint.sh /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh -COPY ./entrypoint.sh / -RUN chmod +x /entrypoint.sh -CMD ["/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["n8n", "start"] diff --git a/README.md b/README.md index 2d0cb7c2c3..190bc6c36e 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,18 @@ This is a [Heroku](https://heroku.com/)-focused container implementation of [n8n](https://n8n.io/). -Use the **Deploy to Heroku** button above to launch n8n on Heroku. When deploying, make sure to check all configuration options and adjust them to your needs. It's especially important to set `N8N_ENCRYPTION_KEY` to a random secure value. +Use the **Deploy to Heroku** button above to launch n8n on Heroku. When deploying, make sure to check all configuration options +and adjust them to your needs. It's especially important to set `N8N_ENCRYPTION_KEY` to a random secure value. Refer to the [Heroku n8n tutorial](https://docs.n8n.io/hosting/server-setups/heroku/) for more information. If you have questions after trying the tutorials, check out the [forums](https://community.n8n.io/). + +## Automatic n8n version management + +This container keeps the n8n CLI up to date without requiring code changes: + +- Set the `N8N_VERSION` config var to pin a specific n8n release. The default value (`latest`) resolves to the newest stable version on each deploy or dyno restart. +- Automatic upgrades can be disabled by setting `N8N_AUTO_UPDATE=false` if you prefer to manage updates manually. + +During startup the entrypoint script compares the installed version with the desired one and installs upgrades when required, ensuring that only n8n itself changes while the rest of the environment remains stable. diff --git a/app.json b/app.json index d6d9c6f14a..7d436e5c56 100644 --- a/app.json +++ b/app.json @@ -1,43 +1,51 @@ { - "name": "n8n", - "description": "deploy n8n to heroku without any hassle", - "keywords": [ - "n8n", - "node", - "automation" - ], - "website": "https://n8n.io", - "repository": "https://github.com/kuromi04/n8n-heroku2025.git", - "logo": "https://raw.githubusercontent.com/n8n-io/n8n-heroku/main/n8n_logo.png", - "success_url": "/", - "stack": "container", - "env": { - "GENERIC_TIMEZONE": { - "description": "Time Zone to use with Heroku. You can find the name of your timezone for example here: https://momentjs.com/timezone/.", - "value": "Europe/Berlin" - }, - "N8N_ENCRYPTION_KEY": { - "description": "Set the n8n encryption key to a static value to avoid Heroku overriding it (causing authentication to fail).", - "value": "change-me-to-something-else" - }, - "WEBHOOK_URL": { - "description": "Replace with your Heroku application name. This will ensure the correct webhook URLs are being shown in n8n.", - "value": "https://.herokuapp.com" - }, - "DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED": { - "description": "SSL is required to connect to Postgres on Heroku", - "value": "false" - } + "name": "n8n", + "description": "Deploy n8n to Heroku without any hassle", + "keywords": [ + "n8n", + "node", + "automation" + ], + "website": "https://n8n.io", + "repository": "https://github.com/kuromi04/n8n-heroku2025.git", + "logo": "https://raw.githubusercontent.com/n8n-io/n8n-heroku/main/n8n_logo.png", + "success_url": "/", + "stack": "container", + "env": { + "GENERIC_TIMEZONE": { + "description": "Time Zone to use with Heroku. You can find the name of your timezone for example here: https://momentjs.com/timezone/.", + "value": "Europe/Berlin" + }, + "N8N_ENCRYPTION_KEY": { + "description": "Set the n8n encryption key to a static value to avoid Heroku overriding it (causing authentication to fail).", + "value": "change-me-to-something-else" + }, + "WEBHOOK_URL": { + "description": "Replace with your Heroku application name. This will ensure the correct webhook URLs are being shown in n8n.", + "value": "https://.herokuapp.com" }, - "addons": [ - { - "plan": "heroku-postgresql", - "options": { - "version": "15" - } - }, - { - "plan": "papertrail:choklad" + "DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED": { + "description": "SSL is required to connect to Postgres on Heroku", + "value": "false" + }, + "N8N_VERSION": { + "description": "Desired n8n release (for example 1.42.0). Leave as 'latest' to automatically install the newest stable version during deploy.", + "value": "latest" + }, + "N8N_AUTO_UPDATE": { + "description": "Set to 'false' to disable automatic updates when the running version differs from N8N_VERSION.", + "value": "true" + } + }, + "addons": [ + { + "plan": "heroku-postgresql", + "options": { + "version": "15" } - ] - } + }, + { + "plan": "papertrail:choklad" + } + ] +} diff --git a/entrypoint.sh b/entrypoint.sh index dced804880..c3baf7f8e6 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,26 +1,137 @@ -#!/bin/sh +#!/usr/bin/env bash +set -euo pipefail -# check if port variable is set or go with default -if [ -z ${PORT+x} ]; then echo "PORT variable not defined, leaving N8N to default port."; else export N8N_PORT="$PORT"; echo "N8N will start on '$PORT'"; fi +DEFAULT_CMD=("n8n" "start") -# regex function -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'#") +log() { + local timestamp + timestamp="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" + printf '[%s] %s\n' "$timestamp" "$*" } -# prefix variables to avoid conflicts and run parse url function on 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')" +configure_port() { + if [ -n "${PORT:-}" ]; then + export N8N_PORT="$PORT" + log "Using Heroku PORT=${PORT} for N8N_PORT." + else + log "PORT is not defined; using the default n8n port." + fi +} + +configure_database() { + if [ -z "${DATABASE_URL:-}" ]; then + log "DATABASE_URL not provided; skipping database configuration." + return + fi + + local db_values + IFS=$'\n' read -r -d '' -a db_values < <(node <<'NODE' && printf '\0' +const urlValue = process.env.DATABASE_URL; +try { + const parsed = new URL(urlValue); + if (!/^postgres/i.test(parsed.protocol)) { + console.log(''); + console.log(''); + console.log(''); + console.log(''); + console.log(''); + process.exit(0); + } + + const withoutLeadingSlash = parsed.pathname ? parsed.pathname.replace(/^\//, '') : ''; + console.log(parsed.hostname ?? ''); + console.log(parsed.port || '5432'); + console.log(parsed.username || ''); + console.log(parsed.password || ''); + console.log(withoutLeadingSlash); +} catch (error) { + console.error(error.message); + process.exit(1); +} +NODE + ) || { + log "Failed to parse DATABASE_URL; aborting."; + exit 1 + } + + # If the protocol was not Postgres we bail out silently. + if [ "${#db_values[@]}" -eq 0 ] || [ -z "${db_values[0]}${db_values[2]}${db_values[4]}" ]; then + log "DATABASE_URL is not a Postgres connection string; skipping database configuration." + return + fi + + export DB_TYPE=postgresdb + export DB_POSTGRESDB_HOST="${db_values[0]}" + export DB_POSTGRESDB_PORT="${db_values[1]}" + export DB_POSTGRESDB_USER="${db_values[2]}" + export DB_POSTGRESDB_PASSWORD="${db_values[3]}" + export DB_POSTGRESDB_DATABASE="${db_values[4]}" + + log "Configured Postgres database ${DB_POSTGRESDB_DATABASE} on ${DB_POSTGRESDB_HOST}:${DB_POSTGRESDB_PORT}." +} + +current_n8n_version() { + n8n --version 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -n1 || true +} + +desired_n8n_version() { + local requested + requested="${N8N_VERSION:-latest}" + if [ "$requested" = "latest" ]; then + npm view n8n version 2>/dev/null || true + else + printf '%s\n' "$requested" + fi +} + +maybe_update_n8n() { + local auto_update + auto_update="${N8N_AUTO_UPDATE:-true}" + + if [ "$auto_update" != "true" ]; then + log "Skipping automatic n8n updates (N8N_AUTO_UPDATE=${auto_update})." + return + fi + + if ! command -v npm >/dev/null 2>&1; then + log "npm is not available; cannot update n8n automatically." + return + fi + + local target_version + target_version="$(desired_n8n_version)" + if [ -z "$target_version" ]; then + log "Unable to determine the desired n8n version; skipping update." + return + fi + + local installed_version + installed_version="$(current_n8n_version)" -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 + if [ "$installed_version" = "$target_version" ]; then + log "n8n ${installed_version} is already installed." + return + fi + + log "Updating n8n from ${installed_version:-unknown} to ${target_version}." + if npm install -g "n8n@${target_version}" --loglevel=error --no-fund; then + log "Successfully updated n8n to version ${target_version}." + else + log "Failed to update n8n; continuing with version ${installed_version:-unknown}." + fi +} + +main() { + if [ "$#" -eq 0 ]; then + set -- "${DEFAULT_CMD[@]}" + fi + + configure_port + configure_database + maybe_update_n8n + + log "Starting n8n with command: $*" + exec "$@" +} -# kickstart nodemation -n8n \ No newline at end of file +main "$@" diff --git a/heroku.yml b/heroku.yml index 5f5fbe9c4a..70226558ad 100644 --- a/heroku.yml +++ b/heroku.yml @@ -1,8 +1,12 @@ setup: - addons: - - plan: heroku-postgresql - as: DATABASE - + addons: + - plan: heroku-postgresql + as: DATABASE build: - docker: - web: Dockerfile \ No newline at end of file + docker: + web: Dockerfile +release: + command: + - n8n migrate:database +run: + web: n8n start From 81108f346cc56cbb5e965bb6a57a646d78b4a91a Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:15:53 -0500 Subject: [PATCH 07/25] Update Heroku PostgreSQL plan to essential-0 --- heroku.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku.yml b/heroku.yml index 70226558ad..91c6c800b0 100644 --- a/heroku.yml +++ b/heroku.yml @@ -1,6 +1,6 @@ setup: addons: - - plan: heroku-postgresql + - plan: heroku-postgresql:essential-0 as: DATABASE build: docker: From e144831db2a36e9f83bc4b43fc7bb91182466a51 Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:23:11 -0500 Subject: [PATCH 08/25] Update Heroku PostgreSQL plan to essential-0 --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index 7d436e5c56..9abd54f910 100644 --- a/app.json +++ b/app.json @@ -39,7 +39,7 @@ }, "addons": [ { - "plan": "heroku-postgresql", + "plan": "heroku-postgresql:essential-0", "options": { "version": "15" } From cd055ab23bcb6ca96167ed3d87d5b353c1a8ae85 Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:43:11 -0500 Subject: [PATCH 09/25] Update Heroku configuration for database and run command --- heroku.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/heroku.yml b/heroku.yml index 91c6c800b0..853440765e 100644 --- a/heroku.yml +++ b/heroku.yml @@ -1,12 +1,9 @@ setup: addons: - - plan: heroku-postgresql:essential-0 - as: DATABASE + - plan: heroku-postgresql:mini build: docker: web: Dockerfile -release: - command: - - n8n migrate:database run: - web: n8n start + web: /entrypoint.sh + From 30eda5d49ddbddfaff9dd1ff3a57ad89c318182a Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:43:42 -0500 Subject: [PATCH 10/25] Update Dockerfile --- Dockerfile | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 45b4cbe734..7591718300 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,9 @@ -# syntax=docker/dockerfile:1 - -ARG N8N_VERSION=latest -FROM n8nio/n8n:${N8N_VERSION} - -# Run as root to allow runtime updates of the n8n CLI when requested. -USER root - -# Replace the entrypoint with a Heroku-friendly bootstrap script that -# prepares the database configuration and optionally keeps n8n updated. -COPY entrypoint.sh /docker-entrypoint.sh -RUN chmod +x /docker-entrypoint.sh - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["n8n", "start"] +FROM n8nio/n8n:latest +# Heroku asigna $PORT; n8n escucha en N8N_PORT +ENV N8N_HOST=0.0.0.0 +ENV N8N_PORT=8080 +EXPOSE 8080 +# Heroku inyecta DATABASE_URL; n8n lo leerá si configuras envs abajo +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +CMD ["/entrypoint.sh"] From 8fe510ce00618a53d27120976d28636b8a28cc36 Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:44:51 -0500 Subject: [PATCH 11/25] Simplify entrypoint.sh and improve database handling Refactor entrypoint.sh to simplify database configuration and remove unused functions. --- entrypoint.sh | 143 ++++---------------------------------------------- 1 file changed, 9 insertions(+), 134 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index c3baf7f8e6..e499a9bc13 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,137 +1,12 @@ #!/usr/bin/env bash -set -euo pipefail - -DEFAULT_CMD=("n8n" "start") - -log() { - local timestamp - timestamp="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" - printf '[%s] %s\n' "$timestamp" "$*" -} - -configure_port() { - if [ -n "${PORT:-}" ]; then - export N8N_PORT="$PORT" - log "Using Heroku PORT=${PORT} for N8N_PORT." - else - log "PORT is not defined; using the default n8n port." - fi -} - -configure_database() { - if [ -z "${DATABASE_URL:-}" ]; then - log "DATABASE_URL not provided; skipping database configuration." - return - fi - - local db_values - IFS=$'\n' read -r -d '' -a db_values < <(node <<'NODE' && printf '\0' -const urlValue = process.env.DATABASE_URL; -try { - const parsed = new URL(urlValue); - if (!/^postgres/i.test(parsed.protocol)) { - console.log(''); - console.log(''); - console.log(''); - console.log(''); - console.log(''); - process.exit(0); - } - - const withoutLeadingSlash = parsed.pathname ? parsed.pathname.replace(/^\//, '') : ''; - console.log(parsed.hostname ?? ''); - console.log(parsed.port || '5432'); - console.log(parsed.username || ''); - console.log(parsed.password || ''); - console.log(withoutLeadingSlash); -} catch (error) { - console.error(error.message); - process.exit(1); -} -NODE - ) || { - log "Failed to parse DATABASE_URL; aborting."; - exit 1 - } - - # If the protocol was not Postgres we bail out silently. - if [ "${#db_values[@]}" -eq 0 ] || [ -z "${db_values[0]}${db_values[2]}${db_values[4]}" ]; then - log "DATABASE_URL is not a Postgres connection string; skipping database configuration." - return - fi - +set -e +# WEBHOOK_URL basado en nombre de app si no se definió +: "${WEBHOOK_URL:=https://${HEROKU_APP_NAME}.herokuapp.com/}" +export WEBHOOK_URL +# Usa la base de datos de Heroku si existe DATABASE_URL +if [ -n "$DATABASE_URL" ]; then export DB_TYPE=postgresdb - export DB_POSTGRESDB_HOST="${db_values[0]}" - export DB_POSTGRESDB_PORT="${db_values[1]}" - export DB_POSTGRESDB_USER="${db_values[2]}" - export DB_POSTGRESDB_PASSWORD="${db_values[3]}" - export DB_POSTGRESDB_DATABASE="${db_values[4]}" - - log "Configured Postgres database ${DB_POSTGRESDB_DATABASE} on ${DB_POSTGRESDB_HOST}:${DB_POSTGRESDB_PORT}." -} - -current_n8n_version() { - n8n --version 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -n1 || true -} - -desired_n8n_version() { - local requested - requested="${N8N_VERSION:-latest}" - if [ "$requested" = "latest" ]; then - npm view n8n version 2>/dev/null || true - else - printf '%s\n' "$requested" - fi -} - -maybe_update_n8n() { - local auto_update - auto_update="${N8N_AUTO_UPDATE:-true}" - - if [ "$auto_update" != "true" ]; then - log "Skipping automatic n8n updates (N8N_AUTO_UPDATE=${auto_update})." - return - fi - - if ! command -v npm >/dev/null 2>&1; then - log "npm is not available; cannot update n8n automatically." - return - fi - - local target_version - target_version="$(desired_n8n_version)" - if [ -z "$target_version" ]; then - log "Unable to determine the desired n8n version; skipping update." - return - fi - - local installed_version - installed_version="$(current_n8n_version)" - - if [ "$installed_version" = "$target_version" ]; then - log "n8n ${installed_version} is already installed." - return - fi - - log "Updating n8n from ${installed_version:-unknown} to ${target_version}." - if npm install -g "n8n@${target_version}" --loglevel=error --no-fund; then - log "Successfully updated n8n to version ${target_version}." - else - log "Failed to update n8n; continuing with version ${installed_version:-unknown}." - fi -} - -main() { - if [ "$#" -eq 0 ]; then - set -- "${DEFAULT_CMD[@]}" - fi - - configure_port - configure_database - maybe_update_n8n - - log "Starting n8n with command: $*" - exec "$@" -} + export DB_POSTGRESDB_CONNECTION_STRING="$DATABASE_URL" +fi +exec n8n start -main "$@" From 81229f35b9c82ccc76fb41069d5ae4cab4cbcd81 Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:45:42 -0500 Subject: [PATCH 12/25] Update app.json for n8n Heroku deployment Updated application name and description for Heroku deployment. Modified environment variables and added basic authentication settings. --- app.json | 55 +++++++++---------------------------------------------- 1 file changed, 9 insertions(+), 46 deletions(-) diff --git a/app.json b/app.json index 9abd54f910..9054a5decd 100644 --- a/app.json +++ b/app.json @@ -1,51 +1,14 @@ { - "name": "n8n", - "description": "Deploy n8n to Heroku without any hassle", - "keywords": [ - "n8n", - "node", - "automation" - ], - "website": "https://n8n.io", - "repository": "https://github.com/kuromi04/n8n-heroku2025.git", - "logo": "https://raw.githubusercontent.com/n8n-io/n8n-heroku/main/n8n_logo.png", - "success_url": "/", + "name": "n8n on Heroku", + "description": "n8n autoservicio en Heroku con 1-click deploy", "stack": "container", "env": { - "GENERIC_TIMEZONE": { - "description": "Time Zone to use with Heroku. You can find the name of your timezone for example here: https://momentjs.com/timezone/.", - "value": "Europe/Berlin" - }, - "N8N_ENCRYPTION_KEY": { - "description": "Set the n8n encryption key to a static value to avoid Heroku overriding it (causing authentication to fail).", - "value": "change-me-to-something-else" - }, - "WEBHOOK_URL": { - "description": "Replace with your Heroku application name. This will ensure the correct webhook URLs are being shown in n8n.", - "value": "https://.herokuapp.com" - }, - "DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED": { - "description": "SSL is required to connect to Postgres on Heroku", - "value": "false" - }, - "N8N_VERSION": { - "description": "Desired n8n release (for example 1.42.0). Leave as 'latest' to automatically install the newest stable version during deploy.", - "value": "latest" - }, - "N8N_AUTO_UPDATE": { - "description": "Set to 'false' to disable automatic updates when the running version differs from N8N_VERSION.", - "value": "true" - } + "N8N_ENCRYPTION_KEY": { "description": "Clave aleatoria segura", "required": true }, + "N8N_BASIC_AUTH_ACTIVE": { "value": "true" }, + "N8N_BASIC_AUTH_USER": { "required": true }, + "N8N_BASIC_AUTH_PASSWORD": { "required": true }, + "N8N_PORT": { "value": "8080" } }, - "addons": [ - { - "plan": "heroku-postgresql:essential-0", - "options": { - "version": "15" - } - }, - { - "plan": "papertrail:choklad" - } - ] + "addons": [{ "plan": "heroku-postgresql:mini" }], + "keywords": ["n8n", "automation", "heroku"] } From 5a705390cedb35f754fd8c45f5ace6b3fbafe73c Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:46:31 -0500 Subject: [PATCH 13/25] Update Heroku deploy button link in README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 190bc6c36e..fe90b3b62c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # n8n-heroku -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https://github.com/kuromi04/n8n-heroku2025.git) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) + ## n8n - Free and open fair-code licensed node based Workflow Automation Tool. From 9717e8909cda1d55e56fe509abc92005ba5f0acf Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:51:59 -0500 Subject: [PATCH 14/25] Change Heroku deploy button link Updated the Heroku deploy button link in README. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fe90b3b62c..05156ba0fd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # n8n-heroku -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/kuromi04/n8n-heroku2025) + ## n8n - Free and open fair-code licensed node based Workflow Automation Tool. From 3eb27b7d8196cdc8977824c535812d193225f71b Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:52:31 -0500 Subject: [PATCH 15/25] Update app.json descriptions and keywords order --- app.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app.json b/app.json index 9054a5decd..015cf1fdcf 100644 --- a/app.json +++ b/app.json @@ -1,14 +1,15 @@ { "name": "n8n on Heroku", - "description": "n8n autoservicio en Heroku con 1-click deploy", + "description": "n8n en Heroku con 1-click deploy", "stack": "container", "env": { - "N8N_ENCRYPTION_KEY": { "description": "Clave aleatoria segura", "required": true }, + "N8N_ENCRYPTION_KEY": { "required": true, "description": "cadena aleatoria segura" }, "N8N_BASIC_AUTH_ACTIVE": { "value": "true" }, "N8N_BASIC_AUTH_USER": { "required": true }, "N8N_BASIC_AUTH_PASSWORD": { "required": true }, "N8N_PORT": { "value": "8080" } }, "addons": [{ "plan": "heroku-postgresql:mini" }], - "keywords": ["n8n", "automation", "heroku"] + "keywords": ["n8n","heroku","automation"] } + From ac93b6eb0e1625f135e2421fcdf3648fd88918ee Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:53:14 -0500 Subject: [PATCH 16/25] Update heroku.yml for PostgreSQL addon setup --- heroku.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku.yml b/heroku.yml index 853440765e..9921f4380a 100644 --- a/heroku.yml +++ b/heroku.yml @@ -1,3 +1,4 @@ +# heroku.yml setup: addons: - plan: heroku-postgresql:mini @@ -6,4 +7,3 @@ build: web: Dockerfile run: web: /entrypoint.sh - From 93c692d76b5f8eb3f5635af13e187cd79fc6308f Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:53:39 -0500 Subject: [PATCH 17/25] Remove comments from Dockerfile --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7591718300..316ea3a0de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,8 @@ +# Dockerfile FROM n8nio/n8n:latest -# Heroku asigna $PORT; n8n escucha en N8N_PORT ENV N8N_HOST=0.0.0.0 ENV N8N_PORT=8080 EXPOSE 8080 -# Heroku inyecta DATABASE_URL; n8n lo leerá si configuras envs abajo COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh CMD ["/entrypoint.sh"] From c27911acd5c3851bcbe9fab75e1da4e5c3b2c88b Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:54:08 -0500 Subject: [PATCH 18/25] Refactor entrypoint.sh for clarity and structure --- entrypoint.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index e499a9bc13..91cce4a2ea 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,12 +1,10 @@ +# entrypoint.sh #!/usr/bin/env bash set -e -# WEBHOOK_URL basado en nombre de app si no se definió : "${WEBHOOK_URL:=https://${HEROKU_APP_NAME}.herokuapp.com/}" export WEBHOOK_URL -# Usa la base de datos de Heroku si existe DATABASE_URL if [ -n "$DATABASE_URL" ]; then export DB_TYPE=postgresdb export DB_POSTGRESDB_CONNECTION_STRING="$DATABASE_URL" fi exec n8n start - From 61c3d404aabd04bfd80c36f7952d29eebbf3bbf7 Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:57:05 -0500 Subject: [PATCH 19/25] Enhance app.json with detailed descriptions and keys Updated descriptions and added encryption key details. --- app.json | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/app.json b/app.json index 015cf1fdcf..627aa59688 100644 --- a/app.json +++ b/app.json @@ -1,15 +1,25 @@ { "name": "n8n on Heroku", - "description": "n8n en Heroku con 1-click deploy", + "description": "Instala n8n en Heroku con despliegue 1-click y actualizaciones simples", "stack": "container", "env": { - "N8N_ENCRYPTION_KEY": { "required": true, "description": "cadena aleatoria segura" }, "N8N_BASIC_AUTH_ACTIVE": { "value": "true" }, - "N8N_BASIC_AUTH_USER": { "required": true }, - "N8N_BASIC_AUTH_PASSWORD": { "required": true }, + "N8N_BASIC_AUTH_USER": { "description": "Usuario para acceder a n8n", "value": "admin" }, + "N8N_BASIC_AUTH_PASSWORD": { "description": "Contraseña para n8n", "value": "changeme" }, + "N8N_ENCRYPTION_KEY": { "description": "Clave de cifrado segura", "value": "use-uuid-generator" }, "N8N_PORT": { "value": "8080" } }, - "addons": [{ "plan": "heroku-postgresql:mini" }], - "keywords": ["n8n","heroku","automation"] + "addons": [ + { "plan": "heroku-postgresql:mini" } + ], + "build": { + "docker": { + "web": "Dockerfile" + } + }, + "run": { + "web": "/entrypoint.sh" + }, + "keywords": ["n8n", "heroku", "automation"] } From 02174200a569e020499bb86c374e5a484ddf4f15 Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:57:38 -0500 Subject: [PATCH 20/25] Fix formatting in README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 05156ba0fd..69061496c5 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ + ## n8n - Free and open fair-code licensed node based Workflow Automation Tool. This is a [Heroku](https://heroku.com/)-focused container implementation of [n8n](https://n8n.io/). From 18457e361738b257d73a661e81c247d6648ffbc0 Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 15:06:58 -0500 Subject: [PATCH 21/25] Update Heroku PostgreSQL plan in app.json --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index 627aa59688..3f3c4894e2 100644 --- a/app.json +++ b/app.json @@ -10,7 +10,7 @@ "N8N_PORT": { "value": "8080" } }, "addons": [ - { "plan": "heroku-postgresql:mini" } + { "plan": "heroku-postgresql: Essential-0" } ], "build": { "docker": { From 49402afd631b2c498f3e26c7544efa660129007c Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 15:21:22 -0500 Subject: [PATCH 22/25] Refactor Dockerfile for entrypoint and permissions --- Dockerfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 316ea3a0de..bd082d472d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ -# Dockerfile FROM n8nio/n8n:latest -ENV N8N_HOST=0.0.0.0 -ENV N8N_PORT=8080 -EXPOSE 8080 -COPY entrypoint.sh /entrypoint.sh + +USER root + +WORKDIR /home/node/packages/cli +ENTRYPOINT [] + +COPY ./entrypoint.sh / RUN chmod +x /entrypoint.sh CMD ["/entrypoint.sh"] From 3630ac416475eece74877c3de11d11968a38250c Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 15:23:01 -0500 Subject: [PATCH 23/25] Revise app.json for n8n Heroku deployment Updated application configuration for n8n deployment on Heroku, including new environment variables, keywords, and repository details. --- app.json | 65 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/app.json b/app.json index 3f3c4894e2..25738ac47a 100644 --- a/app.json +++ b/app.json @@ -1,25 +1,44 @@ { - "name": "n8n on Heroku", - "description": "Instala n8n en Heroku con despliegue 1-click y actualizaciones simples", - "stack": "container", - "env": { - "N8N_BASIC_AUTH_ACTIVE": { "value": "true" }, - "N8N_BASIC_AUTH_USER": { "description": "Usuario para acceder a n8n", "value": "admin" }, - "N8N_BASIC_AUTH_PASSWORD": { "description": "Contraseña para n8n", "value": "changeme" }, - "N8N_ENCRYPTION_KEY": { "description": "Clave de cifrado segura", "value": "use-uuid-generator" }, - "N8N_PORT": { "value": "8080" } - }, - "addons": [ - { "plan": "heroku-postgresql: Essential-0" } - ], - "build": { - "docker": { - "web": "Dockerfile" - } - }, - "run": { - "web": "/entrypoint.sh" - }, - "keywords": ["n8n", "heroku", "automation"] -} + "name": "n8n", + "description": "deploy n8n to heroku without any hassle", + "keywords": [ + "n8n", + "node", + "automation" + ], + "website": "https://n8n.io", + "repository": "https://github.com/n8n-io/n8n-heroku", + "logo": "https://raw.githubusercontent.com/n8n-io/n8n-heroku/main/n8n_logo.png", + "success_url": "/", + "stack": "container", + "env": { + "GENERIC_TIMEZONE": { + "description": "Time Zone to use with Heroku. You can find the name of your timezone for example here: https://momentjs.com/timezone/.", + "value": "Europe/Berlin" + }, + "N8N_ENCRYPTION_KEY": { + "description": "Set the n8n encryption key to a static value to avoid Heroku overriding it (causing authentication to fail).", + "value": "change-me-to-something-else" + }, + "WEBHOOK_URL": { + "description": "Replace with your Heroku application name. This will ensure the correct webhook URLs are being shown in n8n.", + "value": "https://.herokuapp.com" + }, + "DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED": { + "description": "SSL is required to connect to Postgres on Heroku", + "value": "false" + } + }, + "addons": [ + { + "plan": "heroku-postgresql", + "options": { + "version": "17" + } + }, + { + "plan": "papertrail:choklad" + } + ] + } From 00774284665dae10f02a5436527bb01c08907a2d Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 15:23:58 -0500 Subject: [PATCH 24/25] Refactor entrypoint.sh for improved database config Updated entrypoint script to include port handling and URL parsing for database connection. --- entrypoint.sh | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 91cce4a2ea..7460161f82 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,26 @@ -# entrypoint.sh -#!/usr/bin/env bash -set -e -: "${WEBHOOK_URL:=https://${HEROKU_APP_NAME}.herokuapp.com/}" -export WEBHOOK_URL -if [ -n "$DATABASE_URL" ]; then - export DB_TYPE=postgresdb - export DB_POSTGRESDB_CONNECTION_STRING="$DATABASE_URL" -fi -exec n8n start +#!/bin/sh + +# check if port variable is set or go with default +if [ -z ${PORT+x} ]; then echo "PORT variable not defined, leaving N8N to default port."; else export N8N_PORT="$PORT"; echo "N8N will start on '$PORT'"; fi + +# regex function +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'#") +} + +# prefix variables to avoid conflicts and run parse url function on 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')" + +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 + +# kickstart nodemation +n8n From 314d8418092901909c631d2bf0427283aac82920 Mon Sep 17 00:00:00 2001 From: kuromi04 <136554102+kuromi04@users.noreply.github.com> Date: Sat, 18 Oct 2025 15:25:08 -0500 Subject: [PATCH 25/25] Update heroku.yml for PostgreSQL configuration --- heroku.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/heroku.yml b/heroku.yml index 9921f4380a..01ed7e83cb 100644 --- a/heroku.yml +++ b/heroku.yml @@ -1,9 +1,8 @@ -# heroku.yml setup: - addons: - - plan: heroku-postgresql:mini + addons: + - plan: heroku-postgresql + as: DATABASE + build: - docker: - web: Dockerfile -run: - web: /entrypoint.sh + docker: + web: Dockerfile