local-ai-packaged

repository·main·Indexed 26 days ago

https://github.com/coleam00/local-ai-packaged

A self-hosted AI starter kit and Docker Compose template that bundles n8n, Open WebUI, Ollama, Supabase, Qdrant, Flowise, Neo4j, SearXNG, Caddy, and Langfuse to provide a complete local AI development environment.

Tokens
3.2K
Snippets
6
Records
18
Agent score
37%

What's inside local-ai-packaged

  1. Overview of Self-hosted AI Package

    main

    The Self-hosted AI Package is a Docker Compose template designed to bootstrap a complete local AI and low-code development environment. It integrates several key components:

    • n8n: Low-code platform for AI workflows.
    • Supabase: Database, vector store, and authentication.
    • Ollama: Local LLM runner.
    • Open WebUI: Interface for chatting with models and n8n agents.
    • Flowise: Low-code AI agent builder.
    • Qdrant: High-performance vector store.
    • Neo4j: Knowledge graph engine.
    • SearXNG: Privacy-focused metasearch engine.
    • Caddy: HTTPS/TLS management.
    • Langfuse: LLM observability platform.
  2. Enable Local File Trigger and Execute Command nodes in n8n

    main

    In n8n v2+, the Local File Trigger and Execute Command nodes are disabled by default for security. To enable them:

    1. Open docker-compose.yml.
    2. Locate the x-n8n section.
    3. Uncomment the NODES_EXCLUDE line and set it to an empty array: NODES_EXCLUDE=[].
    4. Restart the n8n container using your profile.

    Files accessed via these nodes are located at /data/shared inside the n8n container, which maps to the shared folder in your local directory.

    x-n8n: &service-n8n
      image: n8nio/n8n:latest
      environment:
        # ... other variables ...
        - NODES_EXCLUDE=[]
    docker compose -p localai -f docker-compose.yml --profile <your-profile> up -d n8n
  3. Install the Self-hosted AI Package

    main

    To install the package, clone the stable branch and navigate to the directory:

    git clone -b stable https://github.com/coleam00/local-ai-packaged.git
    cd local-ai-packaged

    Prerequisites

    • Python: Required to run the setup script.
    • Git/GitHub Desktop: For repository management.
    • Docker/Docker Desktop: Required to run all services.
  4. Upgrade all containers

    main

    To update all services (n8n, Open WebUI, etc.) to their latest versions, run the following sequence of commands. Replace <your-profile> with one of: cpu, gpu-nvidia, gpu-amd, or none.

    Note: The start_services.py script does not update containers; you must run the pull command explicitly to get the latest versions.

    # Stop all services
    docker compose -p localai -f docker-compose.yml --profile <your-profile> down
    
    # Pull latest versions of all containers
    docker compose -p localai -f docker-compose.yml --profile <your-profile> pull
    
    # Start services again with your desired profile
    python start_services.py --profile <your-profile>
  5. Connect local Mac Ollama to n8n in Docker

    main

    If you are running Ollama directly on your Mac (not in Docker) and want to use it with the n8n service in Docker, follow these steps:

    1. Modify your Docker Compose file. In the x-n8n section, add the OLLAMA_HOST environment variable:
    x-n8n: &service-n8n
      environment:
        - OLLAMA_HOST=host.docker.internal:11434
    1. Once n8n is running, navigate to http://localhost:5678/home/credentials.
    2. Click on Local Ollama service.
    3. Change the Base URL to http://host.docker.internal:11434/.

    Note: Ensure Ollama is running on your Mac before starting the Docker services.

    x-n8n: &service-n8n
      # ... other configurations ...
      environment:
        # ... other environment variables ...
        - OLLAMA_HOST=host.docker.internal:11434
  6. Run services with start_services.py

    main

    The start_services.py script manages the startup of Supabase and the local AI services. Use the --profile flag to select your hardware configuration and the --environment flag to define the security posture.

    Hardware Profiles

    • Nvidia GPU:
      python start_services.py --profile gpu-nvidia
    • AMD GPU (Linux):
      python start_services.py --profile gpu-amd
    • Mac / Apple Silicon:
      • Full CPU mode: python start_services.py --profile cpu
      • Use local Mac Ollama (connects to Docker via host.docker.internal): python start_services.py --profile none
    • Standard CPU:
      python start_services.py --profile cpu

    Environment Modes

    • private (default): Opens many ports for local development.
    • public: Minimizes attack surface by closing all ports except 80 and 443. Use this for cloud deployments.

    Example for cloud deployment with Nvidia GPU:

    python3 start_services.py --profile gpu-nvidia --environment public
    python start_services.py --profile gpu-nvidia
  7. Import starter n8n workflows

    main

    Pre-built RAG AI Agent workflows are located in the n8n/backup/workflows/ directory. To use them:

    1. Open n8n at http://localhost:5678/ (or your custom domain).
    2. In the workflow list, click the three-dot menu or select Import from File.
    3. Select the JSON files from the n8n/backup/workflows/ folder on your local machine.
    4. Note: You must manually create/configure credentials for each imported workflow to make them functional.
  8. Quick start and usage guide

    main

    Follow these steps to set up and run the self-hosted AI starter kit after installation:

    1. Set up n8n: Open http://localhost:5678/ in your browser to create a local account.
    2. Import Workflows: Import a workflow from n8n/backup/workflows/.
    3. Configure Credentials:
      • Ollama URL: http://ollama:11434
      • Postgres (Supabase): Use DB, username, and password from .env. Host must be db.
      • Qdrant URL: http://qdrant:6333 (API key can be any value).
      • Google Drive: Follow n8n's official guide. Use a custom domain for the redirect URI instead of localhost.
    4. Run Workflow: Select Test workflow. Note: You may need to wait for Ollama to download Llama3.1 (check docker logs).
    5. Activate: Toggle the workflow as active and copy the Production webhook URL.
    6. Set up Open WebUI: Open http://localhost:3000/ and create a local account.
    7. Add n8n Pipe Function:
      • Go to Workspace -> Functions -> Add Function.
      • Provide a name and description, then paste the code from n8n_pipe.py (or use the published version).
      • Click the gear icon and set n8n_url to the Production webhook URL copied in step 5.
      • Toggle the function on. It will now appear in your model dropdown.

    Accessing Services:

    Ollama URL: http://ollama:11434
    Postgres Host: db
    Qdrant URL: http://qdrant:6333
  9. Configure environment variables in .env

    main

    Before running the services, you must set up your environment variables.

    1. Copy .env.example to .env in the project root.
    2. Populate the required secrets. Important: Generate secure random values for all secrets; do not use example values in production.

    Required Variables

    • N8N Configuration:
      • N8N_ENCRYPTION_KEY
      • N8N_USER_MANAGEMENT_JWT_SECRET
    • Supabase Secrets:
      • POSTGRES_PASSWORD
      • JWT_SECRET
      • ANON_KEY
      • SERVICE_ROLE_KEY
      • DASHBOARD_USERNAME
      • DASHBOARD_PASSWORD
      • POOLER_TENANT_ID
    • Neo4j Secrets:
      • NEO4J_AUTH
    • Langfuse credentials:
      • CLICKHOUSE_PASSWORD
      • MINIO_ROOT_PASSWORD
      • LANGFUSE_SALT
      • NEXTAUTH_SECRET
      • ENCRYPTION_KEY

    Migration/Update Notes

    If you are updating an existing installation, you must add these variables to prevent crashes:

    • POOLER_DB_POOL_SIZE=5 (Required if running before June 14th)
    • GLOBAL_S3_BUCKET=stub
    • REGION=stub
    • STORAGE_TENANT_ID=stub
    • S3_PROTOCOL_ACCESS_KEY_ID=625729a08b95bf1b7ff351a663f3a23c
    • S3_PROTOCOL_ACCESS_KEY_SECRET=850181e4652dd023b7a98c58ae0d2d34bd487ee0cc3254aed6eda37307425907
  10. Troubleshoot Supabase and SearXNG issues

    main

    Common fixes for service failures:

    • Supabase Pooler Restarting: Refer to the Supabase GitHub issue.
    • Supabase Analytics Startup Failure: If it fails after changing the Postgres password, delete the folder supabase/docker/volumes/db/data.
    • Docker Desktop: Ensure "Expose daemon on tcp://localhost:2375 without TLS" is enabled in Docker settings.
    • Supabase Service Unavailable: Ensure your Postgres password does not contain an @ character.
    • SearXNG Restarting: Run chmod 755 searxng in the local-ai-packaged folder to allow it to create uwsgi.ini.
    • Missing Supabase Files: If .env or docker-compose.yml are missing in the supabase/ folder, delete the entire supabase/ folder and re-run the setup.
  11. Configure Caddy reverse proxy hostnames

    main

    Caddy acts as a reverse proxy. You can define the hostnames/ports for various services using the following environment variables. If not provided, they default to specific port mappings:

    • N8N_HOSTNAME: Default :8001
    • WEBUI_HOSTNAME: Default :8002
    • FLOWISE_HOSTNAME: Default :8003
    • OLLAMA_HOSTNAME: Default :8004
    • SUPABASE_HOSTNAME: Default :8005
    • SEARXNG_HOSTNAME: Default :8006
    • LANGFUSE_HOSTNAME: Default :8007
    • NEO4J_HOSTNAME: Default :8008
    • LETSENCRYPT_EMAIL: Default internal