Spaces:
Paused
Paused
Fresh upload with Supabase config and HF webhook URL
Browse files- .gitattributes +1 -0
- Dockerfile +70 -97
- README.md +72 -9
.gitattributes
CHANGED
|
@@ -25,6 +25,7 @@
|
|
| 25 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 28 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 29 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 30 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 25 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
CHANGED
|
@@ -1,105 +1,78 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
TZ=Europe/Paris
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
RUN rm -f /etc/apt/sources.list.d/*.list && \
|
| 9 |
-
apt-get update && apt-get install -y --no-install-recommends \
|
| 10 |
curl \
|
| 11 |
-
ca-certificates \
|
| 12 |
-
sudo \
|
| 13 |
-
git \
|
| 14 |
wget \
|
|
|
|
|
|
|
| 15 |
procps \
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
nano \
|
| 22 |
-
bzip2 \
|
| 23 |
-
libx11-6 \
|
| 24 |
-
build-essential \
|
| 25 |
-
libsndfile-dev \
|
| 26 |
-
software-properties-common \
|
| 27 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 28 |
-
|
| 29 |
-
RUN add-apt-repository ppa:flexiondotorg/nvtop && \
|
| 30 |
-
apt-get upgrade -y && \
|
| 31 |
-
apt-get install -y --no-install-recommends nvtop
|
| 32 |
-
|
| 33 |
-
RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
|
| 34 |
-
apt-get install -y nodejs && \
|
| 35 |
-
npm install -g configurable-http-proxy
|
| 36 |
-
|
| 37 |
-
# Create a working directory
|
| 38 |
-
WORKDIR /app
|
| 39 |
-
|
| 40 |
-
# Create a non-root user and switch to it
|
| 41 |
-
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
|
| 42 |
-
&& chown -R user:user /app
|
| 43 |
-
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
|
| 44 |
-
USER user
|
| 45 |
-
|
| 46 |
-
# All users can use /home/user as their home directory
|
| 47 |
-
ENV HOME=/home/user
|
| 48 |
-
RUN mkdir $HOME/.cache $HOME/.config \
|
| 49 |
-
&& chmod -R 777 $HOME
|
| 50 |
-
|
| 51 |
-
# Set up the Conda environment
|
| 52 |
-
ENV CONDA_AUTO_UPDATE_CONDA=false \
|
| 53 |
-
PATH=$HOME/miniconda/bin:$PATH
|
| 54 |
-
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
|
| 55 |
-
&& chmod +x ~/miniconda.sh \
|
| 56 |
-
&& ~/miniconda.sh -b -p ~/miniconda \
|
| 57 |
-
&& rm ~/miniconda.sh \
|
| 58 |
-
&& conda clean -ya
|
| 59 |
-
|
| 60 |
-
WORKDIR $HOME/app
|
| 61 |
-
|
| 62 |
-
#######################################
|
| 63 |
-
# Start root user section
|
| 64 |
-
#######################################
|
| 65 |
-
|
| 66 |
-
USER root
|
| 67 |
-
|
| 68 |
-
# User Debian packages
|
| 69 |
-
## Security warning : Potential user code executed as root (build time)
|
| 70 |
-
RUN --mount=target=/root/packages.txt,source=packages.txt \
|
| 71 |
-
apt-get update && \
|
| 72 |
-
xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
|
| 73 |
&& rm -rf /var/lib/apt/lists/*
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
#######################################
|
| 81 |
-
# End root user section
|
| 82 |
-
#######################################
|
| 83 |
-
|
| 84 |
-
USER user
|
| 85 |
-
|
| 86 |
-
# Python packages
|
| 87 |
-
RUN --mount=target=requirements.txt,source=requirements.txt \
|
| 88 |
-
pip install --no-cache-dir --upgrade -r requirements.txt
|
| 89 |
-
|
| 90 |
-
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 91 |
-
COPY --chown=user . $HOME/app
|
| 92 |
-
|
| 93 |
-
RUN chmod +x start_server.sh
|
| 94 |
-
|
| 95 |
-
COPY --chown=user login.html /home/user/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
|
| 96 |
-
|
| 97 |
-
ENV PYTHONUNBUFFERED=1 \
|
| 98 |
-
GRADIO_ALLOW_FLAGGING=never \
|
| 99 |
-
GRADIO_NUM_PORTS=1 \
|
| 100 |
-
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 101 |
-
GRADIO_THEME=huggingface \
|
| 102 |
-
SYSTEM=spaces \
|
| 103 |
-
SHELL=/bin/bash
|
| 104 |
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a base image with systemd or a process manager if complex, otherwise a simpler base
|
| 2 |
+
# Ubuntu is a good general-purpose choice for installing multiple services
|
| 3 |
+
FROM ubuntu:22.04
|
| 4 |
|
| 5 |
+
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
|
| 6 |
|
| 7 |
+
# Install dependencies: curl, wget, gnupg, sudo, procps (for ps), net-tools (for netstat)
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
|
|
|
|
|
|
| 9 |
curl \
|
|
|
|
|
|
|
|
|
|
| 10 |
wget \
|
| 11 |
+
gnupg \
|
| 12 |
+
sudo \
|
| 13 |
procps \
|
| 14 |
+
net-tools \
|
| 15 |
+
ca-certificates \
|
| 16 |
+
postgresql \
|
| 17 |
+
postgresql-contrib \
|
| 18 |
+
zstd \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
|
| 21 |
+
# --- Install Node.js (e.g., v20.x LTS) ---
|
| 22 |
+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
| 23 |
+
&& apt-get install -y nodejs \
|
| 24 |
+
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
RUN node -v
|
| 27 |
+
RUN npm -v
|
| 28 |
+
|
| 29 |
+
# Install n8n
|
| 30 |
+
RUN npm install -g n8n
|
| 31 |
+
|
| 32 |
+
# Install Qdrant
|
| 33 |
+
ARG QDRANT_VERSION=v1.9.2
|
| 34 |
+
RUN wget "https://github.com/qdrant/qdrant/releases/download/${QDRANT_VERSION}/qdrant-x86_64-unknown-linux-gnu.tar.gz" -O qdrant.tar.gz && \
|
| 35 |
+
tar -xzf qdrant.tar.gz && \
|
| 36 |
+
mv qdrant /usr/local/bin/qdrant && \
|
| 37 |
+
rm qdrant.tar.gz && \
|
| 38 |
+
mkdir -p /qdrant/storage && \
|
| 39 |
+
mkdir -p /qdrant/config
|
| 40 |
+
COPY qdrant_config.yaml /qdrant/config/config.yaml
|
| 41 |
+
|
| 42 |
+
# Install Ollama
|
| 43 |
+
RUN curl -fsSL https://ollama.com/install.sh | sh
|
| 44 |
+
|
| 45 |
+
# Create a non-root user for n8n and other services if possible
|
| 46 |
+
RUN useradd -m -s /bin/bash n8nuser
|
| 47 |
+
RUN mkdir -p /home/n8nuser/.n8n /data/shared /home/n8nuser/.ollama /var/run/postgresql
|
| 48 |
+
RUN chown -R n8nuser:n8nuser /home/n8nuser /data/shared /qdrant /var/run/postgresql
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
# Setup environment variables
|
| 52 |
+
# IMPORTANT: NO end-of-line comments in this ENV block
|
| 53 |
+
ENV N8N_HOST="0.0.0.0"
|
| 54 |
+
ENV N8N_PORT="5678"
|
| 55 |
+
ENV NODE_ENV="production"
|
| 56 |
+
ENV DB_TYPE="postgresdb"
|
| 57 |
+
ENV DB_POSTGRESDB_HOST="localhost"
|
| 58 |
+
ENV DB_POSTGRESDB_PORT="5432"
|
| 59 |
+
ENV DB_POSTGRESDB_DATABASE="n8n"
|
| 60 |
+
ENV DB_POSTGRESDB_USER="n8n"
|
| 61 |
+
ENV OLLAMA_HOST="0.0.0.0:11434"
|
| 62 |
+
ENV N8N_SEC_EMBEDDER_HEADER_ALLOW_FROM_REGEX="^https?:\/\/([a-zA-Z0-9\-]+\.)*hf\.space$"
|
| 63 |
+
ENV N8N_SEC_ALLOW_ALL_ORIGINS_FOR_WEBHOOKS="true"
|
| 64 |
+
ENV N8N_RUNNERS_ENABLED="true"
|
| 65 |
+
|
| 66 |
+
# Copy startup script
|
| 67 |
+
COPY start.sh /start.sh
|
| 68 |
+
RUN chmod +x /start.sh
|
| 69 |
+
|
| 70 |
+
# Expose n8n port
|
| 71 |
+
EXPOSE 5678
|
| 72 |
+
EXPOSE 11434
|
| 73 |
+
EXPOSE 6333
|
| 74 |
+
EXPOSE 5432
|
| 75 |
+
|
| 76 |
+
RUN mkdir -p /data/.n8n /data/postgres /data/qdrant_storage /data/.ollama && chown -R n8nuser:n8nuser /data
|
| 77 |
+
USER n8nuser
|
| 78 |
+
ENTRYPOINT ["/start.sh"]
|
README.md
CHANGED
|
@@ -1,13 +1,76 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: n8n Self-Hosted AI Starter Kit
|
| 3 |
+
emoji: ๐
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 5678
|
| 8 |
+
pinned: true
|
| 9 |
+
# Add hardware requests if needed, e.g. for Ollama with larger models
|
| 10 |
+
# hardware: cpu-upgrade # or gpu-small / gpu-a10g-small etc.
|
| 11 |
+
# For GPU, Ollama should pick it up if drivers are compatible.
|
| 12 |
+
# This Dockerfile is built for CPU by default for wider compatibility.
|
| 13 |
+
persistent_storage:
|
| 14 |
+
# Request persistent storage. Adjust size as needed for models, db, etc.
|
| 15 |
+
# n8n data, postgres db, qdrant vectors, ollama models
|
| 16 |
+
# Example: 10Gi for models and data
|
| 17 |
+
data:
|
| 18 |
+
type: "disk"
|
| 19 |
+
size: 10 # GiB
|
| 20 |
+
mount_path: "/data" # This is where it will be mounted in the container
|
| 21 |
---
|
| 22 |
|
| 23 |
+
# n8n Self-Hosted AI Starter Kit on Hugging Face Spaces
|
| 24 |
+
|
| 25 |
+
This Space deploys the [n8n Self-Hosted AI Starter Kit](https://github.com/n8n-io/self-hosted-ai-starter-kit) in a single container environment. It includes:
|
| 26 |
+
|
| 27 |
+
* **n8n**: Low-code automation platform.
|
| 28 |
+
* **Ollama**: Run local LLMs.
|
| 29 |
+
* **Qdrant**: Vector database.
|
| 30 |
+
* **PostgreSQL**: Database for n8n.
|
| 31 |
+
|
| 32 |
+
## Setup
|
| 33 |
+
|
| 34 |
+
1. **Secrets**:
|
| 35 |
+
Before this Space can run correctly, you **MUST** configure the following secrets in your Space settings:
|
| 36 |
+
* `N8N_ENCRYPTION_KEY`: A long, random string for encrypting sensitive n8n data.
|
| 37 |
+
* Generate one with: `openssl rand -hex 32`
|
| 38 |
+
* `DB_POSTGRESDB_PASSWORD`: Password for the PostgreSQL `n8n` user and database.
|
| 39 |
+
* Choose a strong password.
|
| 40 |
+
|
| 41 |
+
2. **Wait for Build**: The first time, the Docker image will build, and services will start. This can take a few minutes. The `start.sh` script will also pull a default Ollama model (`llama3.1:8b` or similar small model), which can take time.
|
| 42 |
+
|
| 43 |
+
3. **Access n8n**: Once the Space is running, click the "Open app" button or use the direct URL to access n8n on port 5678.
|
| 44 |
+
|
| 45 |
+
## How to Use
|
| 46 |
+
|
| 47 |
+
1. **n8n First-Time Setup**: When you first access n8n, you'll be prompted to create an owner account.
|
| 48 |
+
2. **Local Services**:
|
| 49 |
+
* **Ollama**: Running on `http://localhost:11434` (internally within the Space). The default model (`llama3.1:8b` or similar) should be available. You can use the "Ollama" node in n8n and set its "Base URL" to `http://localhost:11434`.
|
| 50 |
+
* **Qdrant**: Running on `http://localhost:6333` (internally). Use the "Qdrant" node in n8n and set its "URL" to `http://localhost:6333`.
|
| 51 |
+
* **PostgreSQL**: n8n is already configured to use the internal PostgreSQL instance.
|
| 52 |
+
3. **Persistent Storage**:
|
| 53 |
+
* n8n workflows and credentials are stored in `/data/.n8n`.
|
| 54 |
+
* PostgreSQL data is stored in `/data/postgres`.
|
| 55 |
+
* Qdrant vector data is stored in `/data/qdrant_storage`.
|
| 56 |
+
* Ollama models are stored in `/data/.ollama`.
|
| 57 |
+
This data will persist across Space restarts if you've configured persistent storage for `/data`.
|
| 58 |
+
|
| 59 |
+
4. **Accessing Local Files in n8n**:
|
| 60 |
+
The original starter kit mentions a `/data/shared` directory for n8n to access local files. This directory is available in this Space. When using n8n nodes like "Read/Write Files from Disk", use paths like `/data/shared/yourfile.txt`.
|
| 61 |
+
|
| 62 |
+
## Important Notes & Limitations
|
| 63 |
+
|
| 64 |
+
* **Single Container**: All services (n8n, Postgres, Qdrant, Ollama) run in a single Docker container. This is less robust than a multi-container `docker-compose` setup but necessary for this Hugging Face Space deployment model.
|
| 65 |
+
* **Resource Usage**: Running all these services, especially Ollama with LLMs, can be resource-intensive. Ensure your Space has adequate CPU, RAM, and storage. Consider upgrading hardware if performance is slow.
|
| 66 |
+
* **Ollama Model Management**:
|
| 67 |
+
* A default model is pulled on startup.
|
| 68 |
+
* To pull other models, you would typically exec into the container (possible via `hf cli` or other tools, but not directly via the Space UI) and run `ollama pull <modelname>`. Alternatively, some n8n Ollama nodes might trigger a download if the model isn't present (behavior may vary).
|
| 69 |
+
* **Initial Startup Time**: The first startup might be slow due to database initialization and model download. Check the logs for progress.
|
| 70 |
+
* **WEBHOOK_URL / N8N_EDITOR_BASE_URL**: These are automatically configured by the `start.sh` script to use the Hugging Face Space URL.
|
| 71 |
+
|
| 72 |
+
## Troubleshooting
|
| 73 |
+
|
| 74 |
+
* Check the Space logs for any errors during startup or operation.
|
| 75 |
+
* Ensure secrets are correctly set.
|
| 76 |
+
* If n8n is inaccessible, one of the backend services might have failed to start.
|