Skip to content

Add n8n Integration #1540

Description

@lolochristen

Aspire issue link

No response

Overview

Add an Integration for n8n to run and configure a self-hosted n8n environment.
I have already built this extension and happy to integrate into the CommunityToolkit. I can provide a PR Draft any time.
It supports the following scenarios:

  • Simple hosted n8n environment (uses SQLite)
  • Persistence with postgres (WithPostgresDatabase)
  • Distributed Worker Container (AddWorker / WithQueueMode) using redis
  • Isolated TaskRunner Container (AddTaskRunner) to support full scripting support. For deployments, the TaskRunner should be a sidecar of the worker.
  • Setup of some parameters (WithLicenseKey. WithInstanceOwner, WithTimeZone, WithCommunityPackages, WithMetrics)

I have tested and tuned the extension by deploying environments on Azure Container Apps.

Usage example

Simple setup with SQLite:

var builder = DistributedApplication.CreateBuilder(args);
var n8n = builder.AddN8n("n8n");
builder.Build().Run();

Complex scenario with postgres db for persitence, worker (queues for scaling) and task runner (for isolation and support for pyhton script) and owner and licence key config:

var builder = DistributedApplication.CreateBuilder(args);

var ownerPassword = builder.AddParameter("owner-password", "Pass$Word1");
var licenseKey = builder.AddParameter("license-key", "[license-key]");

var postgres = builder.AddPostgres("postgres")
    .WithDataVolume();

var db = postgres.AddDatabase("n8n-db");

var redis = builder.AddRedis("redis");

var n8n = builder.AddN8n("n8n", port: 5678)
    .WithDataBindMount("./.n8n_data")
    .WithPostgresDatabase(db)
    .WithQueueMode(redis)
    .WithInstanceOwner("admin@dev.local", "Admin", "Local", ownerPassword)
    .WithLicenseKey(licenseKey);

var worker = n8n.AddWorker("worker", port: 5679)
    .WithPostgresDatabase(db)
    .WithQueueMode(redis);

worker.AddTaskRunner("runner");

builder.Build().Run();

Remark: The password needs to be encrypted using BCrypt. I have used BCrypt.Net-Next library to make that work.

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions