Skip to content

gofrolist/n8n-selfhosted

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

n8n Self-Hosted on Fly.io

Self-hosted n8n automation platform with SQLite (default) or Supabase PostgreSQL.

Quick Start

Automated (Recommended):

./quickstart.sh              # Interactive script - asks minimal questions

Manual:

# 1. Initialize
make init
vi .env                      # Set FLY_APP_NAME, FLY_REGION, DB_TYPE (sqlite/postgresdb)

# 2. Create Fly.io app
make app-create

# 3. Create persistent volume
make volume-create           # Creates 10GB volume for data storage

# 4. Setup and deploy
make setup
make deploy

# Done! Access at https://n8n-selfhosted.fly.dev

Prerequisites

Before running the quickstart, ensure you have:

  1. Fly.io account - Sign up and install CLI:

    brew install flyctl
    fly auth login
  2. Supabase project ⚠️ Only required if using Supabase database

    • If you choose SQLite (default), no database setup is needed
    • If you choose Supabase, create a project at supabase.com or via CLI
    • Free tier includes 500MB database
    • Save your project reference and database password - you'll need these when running ./quickstart.sh
    • To get the password:
      • If created via web: Go to Project → Settings → Database
      • If created via CLI: Use --db-password flag when creating, or retrieve from dashboard
  3. openssl - Usually pre-installed on macOS/Linux

.env Template

Create .env with:

# Fly.io
FLY_APP_NAME=n8n-selfhosted
FLY_REGION=lax

# Database (sqlite or postgresdb)
DB_TYPE=sqlite

# Supabase Database (only required if DB_TYPE=postgresdb)
SUPABASE_PROJECT_REF=your-project-ref
SUPABASE_DB_PASSWORD=your-database-password

Common Commands

make help              # Show all commands
make volume-create     # Create persistent volume
fly status             # Check app status
fly logs               # View logs
fly apps restart       # Restart app

Features

  • Idempotent - Safe to run multiple times
  • Validated - Checks config before deploying
  • Automated - Generates encryption keys
  • Secure - Secrets never committed

Architecture

  • App: n8n (latest) on Fly.io
  • Database: SQLite (default) or Supabase PostgreSQL (optional)
  • Storage: Persistent volume (filesystem mode)
  • Region: Configurable (default: Los Angeles)
  • HTTPS: Automatic via Fly.io

Cost Estimate

With SQLite (default):

Service Tier Cost/month
Fly.io (1GB RAM, 1 CPU) Paid $2-5
Total $2-5

With Supabase:

Service Tier Cost/month
Fly.io (2GB RAM, 2 CPUs) Paid $5-10
Supabase (500MB DB) Free $0
Total $5-10

Can run on smaller Fly.io VM (512MB RAM, 1 CPU) for ~$2-3/month.

Documentation

Database Operations

SQLite (default):

  • Database file stored in persistent volume at /data/database.sqlite
  • Backup: Copy the database file from the volume
  • No external setup required

Supabase PostgreSQL: See doc/SETUP.md for detailed database operations:

  • Connect: psql "postgresql://postgres:PASSWORD@PROJECT.supabase.co:5432/postgres"
  • Backup: pg_dump "postgresql://..." > backup.sql
  • Restore: psql "postgresql://..." < backup.sql

Troubleshooting

make check                 # Validate everything
fly secrets list           # List secrets
fly ssh console            # SSH into container
fly status                 # Check app status
fly logs                   # View logs
fly apps restart           # Restart app

Security

  • Secrets stored in Fly.io (not in git)
  • Encryption key auto-generated
  • HTTPS enabled by default
  • Database uses SSL connections
  • .env is gitignored

Development

# Check status
fly status

# View logs
fly logs

# Make changes
# ...

# Deploy
make deploy

Support

  • Run make help for all commands
  • See doc/ for detailed guides
  • n8n docs: docs.n8n.io

License

This setup is MIT licensed. n8n is available under fair-code license.

About

Automate selfhosted n8n installation to fly.io

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published