Setting up n8n automation on the fly.io network
As far as back end automation goes, n8n offers an amazing set of features and plugins. We love to use it so I wanted to create a quick guide on how to self host it easily within just a few steps. This guide assumes that you already have flyctl set up. If not, use our guide on that here.
Set up a new fly project
Create a fly.toml file to start your project. You may use the example below. You can adjust the Executions settings if you need more history. I have it like that to save database space.
# fly.toml app configuration file generated for blle-n8n on 2024-02-01T21:07:37-06:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = 'your-app-name'
primary_region = 'pick a reagion'
[build]
image = 'n8nio/n8n'
[env]
GENERIC_TIMEZONE = 'America/Chicago'
N8N_DIAGNOSTICS_ENABLED = 'false'
N8N_HIRING_BANNER_ENABLED = 'false'
N8N_HOST = 'your-app-name.fly.dev'
N8N_PORT = '8080'
N8N_PROTOCOL = 'https'
TINI_SUBREAPER = 'true'
WEBHOOK_URL = 'the url to the fly server'
EXECUTIONS_DATA_PRUNE = 'true'
EXECUTIONS_DATA_MAX_AGE = '168'
EXECUTIONS_DATA_PRUNE_MAX_COUNT='10000'
[[mounts]]
source = 'n8n_vol'
destination = '/home/node/.n8n'
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 1
processes = ['app']
[http_service.concurrency]
hard_limit = 100
soft_limit = 50
type = "connections"
[[vm]]
cpu_kind = 'shared'
cpus = 1
memory_mb = 512
Create a volume to store your database so you don't loose your work between reboots.
flyctl volumes create n8n_vol
Now you can deploy your self hosted instance of n8n.
flyctl deploy
##Update your instance as new releases roll out
The n8n team does an amazing job of rolling out updates so you will want to do this every few weeks or so. This command will get you the latest version installed.
flyctl deploy --no-cache