Leon4gr45 commited on
Commit
14b700e
·
verified ·
1 Parent(s): f128012

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -25,7 +25,6 @@
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
 
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
Dockerfile CHANGED
@@ -1,47 +1,105 @@
1
- # Minimal n8n Dockerfile for Hugging Face Space
2
- FROM ubuntu:22.04
3
 
4
- ARG DEBIAN_FRONTEND=noninteractive
 
5
 
6
- RUN apt-get update && apt-get install -y curl wget gnupg sudo procps net-tools ca-certificates postgresql postgresql-contrib zstd && rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/*
 
 
9
 
10
- RUN npm install -g n8n
 
 
11
 
12
- ARG QDRANT_VERSION=v1.9.2
13
- RUN wget "https://github.com/qdrant/qdrant/releases/download/${QDRANT_VERSION}/qdrant-x86_64-unknown-linux-gnu.tar.gz" -O qdrant.tar.gz && tar -xzf qdrant.tar.gz && mv qdrant /usr/local/bin/qdrant && rm qdrant.tar.gz && mkdir -p /qdrant/storage && mkdir -p /qdrant/config
14
- COPY qdrant_config.yaml /qdrant/config/config.yaml
15
 
16
- RUN curl -fsSL https://ollama.com/install.sh | sh
 
 
 
 
17
 
18
- RUN useradd -m -s /bin/bash n8nuser
19
- RUN mkdir -p /home/n8nuser/.n8n /data/shared /home/n8nuser/.ollama /var/run/postgresql
20
- RUN chown -R n8nuser:n8nuser /home/n8nuser /data/shared /qdrant /var/run/postgresql
 
21
 
22
- # Environment variables - n8n will use these for OAuth callback validation
23
- ENV N8N_PORT="5678"
24
- ENV N8N_URL="https://n8n-clickup-oauth-proxy.vercel.app/"
25
- ENV N8N_PROTOCOL="https"
26
- ENV N8N_HOST="n8n-clickup-oauth-proxy.vercel.app"
27
- ENV N8N_EDITOR_BASE_URL="https://n8n-clickup-oauth-proxy.vercel.app/"
28
- ENV WEBHOOK_URL="https://n8n-clickup-oauth-proxy.vercel.app/"
29
- ENV N8N_TRUST_PROXY="true"
30
- ENV NODE_ENV="production"
31
- ENV DB_TYPE="postgresdb"
32
- ENV DB_POSTGRESDB_HOST="localhost"
33
- ENV DB_POSTGRESDB_PORT="5432"
34
- ENV DB_POSTGRESDB_DATABASE="n8n"
35
- ENV DB_POSTGRESDB_USER="n8n"
36
- ENV OLLAMA_HOST="0.0.0.0:11434"
37
 
38
- COPY start.sh /start.sh
39
- RUN chmod +x /start.sh
40
 
41
- EXPOSE 5678
42
- EXPOSE 11434
43
- EXPOSE 6333
44
- EXPOSE 5432
45
 
46
  USER root
47
- ENTRYPOINT ["/start.sh"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04
 
2
 
3
+ ENV DEBIAN_FRONTEND=noninteractive \
4
+ TZ=Europe/Paris
5
 
6
+ # Remove any third-party apt sources to avoid issues with expiring keys.
7
+ # Install some basic utilities
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
+ git-lfs \
17
+ zip \
18
+ unzip \
19
+ htop \
20
+ vim \
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
+ RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
76
+ bash /root/on_startup.sh
77
+
78
+ RUN mkdir /data && chown user:user /data
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
+ CMD ["./start_server.sh"]
README.md CHANGED
@@ -1,76 +1,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.
 
1
  ---
2
+ title: WebvoyagerResults
3
+ emoji: 💻🐳
4
+ colorFrom: gray
5
+ colorTo: green
6
  sdk: docker
7
+ pinned: false
8
+ tags:
9
+ - jupyterlab
10
+ suggested_storage: small
 
 
 
 
 
 
 
 
 
 
11
  ---
12
 
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
login.html ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends "page.html" %}
2
+
3
+
4
+ {% block stylesheet %}
5
+ {% endblock %}
6
+
7
+ {% block site %}
8
+
9
+ <div id="jupyter-main-app" class="container">
10
+
11
+ <img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="Hugging Face Logo">
12
+ <h4>Welcome to JupyterLab</h4>
13
+
14
+ <h5>The default token is <span style="color:orange;">huggingface</span></h5>
15
+
16
+ {% if login_available %}
17
+ {# login_available means password-login is allowed. Show the form. #}
18
+ <div class="row">
19
+ <div class="navbar col-sm-8">
20
+ <div class="navbar-inner">
21
+ <div class="container">
22
+ <div class="center-nav">
23
+ <form action="{{base_url}}login?next={{next}}" method="post" class="navbar-form pull-left">
24
+ {{ xsrf_form_html() | safe }}
25
+ {% if token_available %}
26
+ <label for="password_input"><strong>{% trans %}Jupyter token <span title="This is the secret you set up when deploying your JupyterLab space">ⓘ</span> {% endtrans
27
+ %}</strong></label>
28
+ {% else %}
29
+ <label for="password_input"><strong>{% trans %}Jupyter password:{% endtrans %}</strong></label>
30
+ {% endif %}
31
+ <input type="password" name="password" id="password_input" class="form-control">
32
+ <button type="submit" class="btn btn-default" id="login_submit">{% trans %}Log in{% endtrans
33
+ %}</button>
34
+ </form>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ {% else %}
41
+ <p>{% trans %}No login available, you shouldn't be seeing this page.{% endtrans %}</p>
42
+ {% endif %}
43
+
44
+ <h5>If you don't have the credentials for this Jupyter space, <a target="_blank" href="https://huggingface.co/spaces/SpacesExamples/jupyterlab?duplicate=true">create your own.</a></h5>
45
+ <br>
46
+
47
+ <p>This template was created by <a href="https://twitter.com/camenduru" target="_blank" >camenduru</a> and <a href="https://huggingface.co/nateraw" target="_blank" >nateraw</a>, with contributions of <a href="https://huggingface.co/osanseviero" target="_blank" >osanseviero</a> and <a href="https://huggingface.co/azzr" target="_blank" >azzr</a> </p>
48
+ {% if message %}
49
+ <div class="row">
50
+ {% for key in message %}
51
+ <div class="message {{key}}">
52
+ {{message[key]}}
53
+ </div>
54
+ {% endfor %}
55
+ </div>
56
+ {% endif %}
57
+ {% if token_available %}
58
+ {% block token_message %}
59
+
60
+ {% endblock token_message %}
61
+ {% endif %}
62
+ </div>
63
+
64
+ {% endblock %}
65
+
66
+
67
+ {% block script %}
68
+ {% endblock %}
n8n/.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar 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
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
n8n/Dockerfile ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Minimal n8n Dockerfile for Hugging Face Space
2
+ FROM ubuntu:22.04
3
+
4
+ ARG DEBIAN_FRONTEND=noninteractive
5
+
6
+ RUN apt-get update && apt-get install -y curl wget gnupg sudo procps net-tools ca-certificates postgresql postgresql-contrib zstd && rm -rf /var/lib/apt/lists/*
7
+
8
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/*
9
+
10
+ RUN npm install -g n8n
11
+
12
+ ARG QDRANT_VERSION=v1.9.2
13
+ RUN wget "https://github.com/qdrant/qdrant/releases/download/${QDRANT_VERSION}/qdrant-x86_64-unknown-linux-gnu.tar.gz" -O qdrant.tar.gz && tar -xzf qdrant.tar.gz && mv qdrant /usr/local/bin/qdrant && rm qdrant.tar.gz && mkdir -p /qdrant/storage && mkdir -p /qdrant/config
14
+ COPY qdrant_config.yaml /qdrant/config/config.yaml
15
+
16
+ RUN curl -fsSL https://ollama.com/install.sh | sh
17
+
18
+ RUN useradd -m -s /bin/bash n8nuser
19
+ RUN mkdir -p /home/n8nuser/.n8n /data/shared /home/n8nuser/.ollama /var/run/postgresql
20
+ RUN chown -R n8nuser:n8nuser /home/n8nuser /data/shared /qdrant /var/run/postgresql
21
+
22
+ # Environment variables - n8n will use these for OAuth callback validation
23
+ ENV N8N_PORT="5678"
24
+ ENV N8N_URL="https://n8n-clickup-oauth-proxy.vercel.app/"
25
+ ENV N8N_PROTOCOL="https"
26
+ ENV N8N_HOST="n8n-clickup-oauth-proxy.vercel.app"
27
+ ENV N8N_EDITOR_BASE_URL="https://n8n-clickup-oauth-proxy.vercel.app/"
28
+ ENV WEBHOOK_URL="https://n8n-clickup-oauth-proxy.vercel.app/"
29
+ ENV N8N_TRUST_PROXY="true"
30
+ ENV NODE_ENV="production"
31
+ ENV DB_TYPE="postgresdb"
32
+ ENV DB_POSTGRESDB_HOST="localhost"
33
+ ENV DB_POSTGRESDB_PORT="5432"
34
+ ENV DB_POSTGRESDB_DATABASE="n8n"
35
+ ENV DB_POSTGRESDB_USER="n8n"
36
+ ENV OLLAMA_HOST="0.0.0.0:11434"
37
+
38
+ COPY start.sh /start.sh
39
+ RUN chmod +x /start.sh
40
+
41
+ EXPOSE 5678
42
+ EXPOSE 11434
43
+ EXPOSE 6333
44
+ EXPOSE 5432
45
+
46
+ USER root
47
+ ENTRYPOINT ["/start.sh"]
n8n/README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
n8n/qdrant_config.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Basic Qdrant configuration
2
+ storage:
3
+ # Storage path for segment snapshots
4
+ # actual data will be in /qdrant/storage/
5
+ storage_path: /qdrant/storage
6
+ # Path to snapshot, used for backup and recovery
7
+ snapshots_path: /qdrant/snapshots
8
+ # If true - point value requests are served from RocksDB, default: false
9
+ # If false - point values are served from RAM. Significant speedup for small vectors
10
+ on_disk_payload: true
11
+ # Path to WAL, default: "{storage_path}/wal"
12
+ # wal:
13
+ # wal_capacity_mb: 32
14
+ # wal_segments_ahead: 0
15
+
16
+ # Service configuration
17
+ service:
18
+ host: 0.0.0.0 # Listen on all interfaces
19
+ http_port: 6333
20
+ grpc_port: 6334
21
+ # Max number of concurrent requests, default 2 * N_CPU
22
+ # max_request_size_mb: 32 # Max total size of POST body in MB, default 32MB
23
+ # enable_cors: true # default
24
+ # enable_tls: false # default
n8n/start.sh ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e # Exit immediately if a command exits with a non-zero status.
3
+
4
+ echo "--- Script Start ---"
5
+ echo "Running as user: $(whoami) (UID: $(id -u), GID: $(id -g))"
6
+
7
+ # --- Persistent Data Setup ---
8
+ N8N_DATA_DIR="/data/.n8n"
9
+ POSTGRES_DATA_DIR="/data/postgres"
10
+ QDRANT_DATA_DIR="/data/qdrant_storage"
11
+ OLLAMA_MODELS_DIR="/data/.ollama"
12
+
13
+ echo "Ensuring application data directories exist..."
14
+
15
+ # Create directories if they don't exist (may need root permissions)
16
+ if [ ! -d "/data" ]; then
17
+ echo "Creating /data directory..."
18
+ mkdir -p /data
19
+ fi
20
+
21
+ # Try to create subdirectories, if we fail (permission denied), assume we're not root
22
+ # and the directories should already exist with correct permissions from HF
23
+ if ! mkdir -p "$N8N_DATA_DIR" "$POSTGRES_DATA_DIR" "$QDRANT_DATA_DIR" "$OLLAMA_MODELS_DIR" 2>/dev/null; then
24
+ echo "Note: Could not create directories (may already exist or permission denied). Continuing..."
25
+ fi
26
+
27
+ # Change ownership to n8nuser if we have permissions
28
+ if [ "$(id -u)" -eq 0 ]; then
29
+ echo "Running as root. Changing ownership of /data to n8nuser..."
30
+ chown -R n8nuser:n8nuser /data
31
+ chmod -R u+rwx /data
32
+ echo "Ownership changed successfully."
33
+ else
34
+ echo "Not running as root. Checking current permissions..."
35
+ fi
36
+
37
+ echo "Permissions of data directories in /data:"
38
+ ls -ld "$N8N_DATA_DIR" "$POSTGRES_DATA_DIR" "$QDRANT_DATA_DIR" "$OLLAMA_MODELS_DIR" 2>/dev/null || echo "Some directories may not exist yet."
39
+
40
+ ln -sfn "$N8N_DATA_DIR" /home/n8nuser/.n8n
41
+ export OLLAMA_MODELS="$OLLAMA_MODELS_DIR"
42
+
43
+ # --- PostgreSQL Setup & Start (as n8nuser) ---
44
+ echo "--- PostgreSQL Setup (running as $(whoami)) ---"
45
+ echo "PGDATA is set to: $POSTGRES_DATA_DIR"
46
+ POSTGRES_PORT="${DB_POSTGRESDB_PORT:-5432}" # Define port for consistency
47
+
48
+ # Ensure n8nuser has rwx permissions on its own PGDATA.
49
+ chmod u+rwx "$POSTGRES_DATA_DIR"
50
+
51
+ if [ ! -d "$POSTGRES_DATA_DIR/base" ]; then
52
+ echo "Initializing PostgreSQL database in $POSTGRES_DATA_DIR as user n8nuser..."
53
+ su - n8nuser -c "/usr/lib/postgresql/14/bin/initdb -D '$POSTGRES_DATA_DIR' --username=n8nuser --no-locale --encoding=UTF8"
54
+ if [ $? -ne 0 ]; then echo "ERROR: PostgreSQL initdb failed."; ls -ld "$POSTGRES_DATA_DIR"; exit 1; fi
55
+
56
+ echo "PostgreSQL Initialized. Ownership/permissions of $POSTGRES_DATA_DIR after initdb:"
57
+ ls -ld "$POSTGRES_DATA_DIR"
58
+
59
+ echo "Temporarily starting PostgreSQL to create database role and database..."
60
+ # For pg_ctl, it's good practice to point to the PGDATA explicitly.
61
+ # pg_ctl will find postgresql.conf within PGDATA.
62
+ su - n8nuser -c "/usr/lib/postgresql/14/bin/pg_ctl -D '$POSTGRES_DATA_DIR' -o \"-p $POSTGRES_PORT -c listen_addresses='localhost'\" -w start"
63
+
64
+ PG_ROLE_NAME="${DB_POSTGRESDB_USER:-n8n}"
65
+ PG_PASSWORD="${DB_POSTGRESDB_PASSWORD}"
66
+ PG_DB_NAME="${DB_POSTGRESDB_DATABASE:-n8n}"
67
+
68
+ if [ -z "$PG_PASSWORD" ]; then echo "ERROR: DB_POSTGRESDB_PASSWORD is not set."; exit 1; fi
69
+
70
+ echo "Creating PostgreSQL role '$PG_ROLE_NAME' and database '$PG_DB_NAME'..."
71
+ su - n8nuser -c "psql -v ON_ERROR_STOP=1 --username=n8nuser --port='$POSTGRES_PORT' --host=localhost postgres <<-EOSQL
72
+ CREATE ROLE \"$PG_ROLE_NAME\" WITH LOGIN PASSWORD '$PG_PASSWORD';
73
+ CREATE DATABASE \"$PG_DB_NAME\" OWNER \"$PG_ROLE_NAME\";
74
+ EOSQL
75
+ "
76
+ echo "PostgreSQL role and database created."
77
+ su - n8nuser -c "/usr/lib/postgresql/14/bin/pg_ctl -D '$POSTGRES_DATA_DIR' -m fast -w stop"
78
+ echo "Temporary PostgreSQL server stopped."
79
+ else
80
+ echo "PostgreSQL database found in $POSTGRES_DATA_DIR."
81
+ fi
82
+
83
+ echo "Starting PostgreSQL server for application use (as n8nuser)..."
84
+ # Switch to n8nuser for running services
85
+ su - n8nuser -c "/usr/lib/postgresql/14/bin/postgres -D '$POSTGRES_DATA_DIR' -p '$POSTGRES_PORT'" &
86
+ PG_PID=$!
87
+ echo "Waiting for PostgreSQL to start (PID: $PG_PID)..."
88
+ max_wait=30
89
+ count=0
90
+ until pg_isready -h localhost -p "$POSTGRES_PORT" -U n8nuser -q || [ $count -eq $max_wait ]; do
91
+ echo -n "."
92
+ sleep 1
93
+ count=$((count+1))
94
+ done
95
+ if [ $count -eq $max_wait ]; then
96
+ echo "ERROR: PostgreSQL timed out waiting to start."
97
+ PG_LOG_DIR_GUESS="$POSTGRES_DATA_DIR/log"
98
+ if [ -d "$PG_LOG_DIR_GUESS" ]; then
99
+ echo "PostgreSQL logs from $PG_LOG_DIR_GUESS:"
100
+ # List log files before cat'ing, and cat only the latest ones if possible or just one
101
+ ls -lt "$PG_LOG_DIR_GUESS"
102
+ cat "$PG_LOG_DIR_GUESS"/postgresql-*.log 2>/dev/null || echo "No standard log files found or readable."
103
+ else
104
+ echo "$PG_LOG_DIR_GUESS not found."
105
+ fi
106
+ exit 1
107
+ fi
108
+ echo "PostgreSQL started successfully on port $POSTGRES_PORT."
109
+
110
+
111
+ # --- Qdrant Setup & Start (as n8nuser) ---
112
+ # (This section remains the same)
113
+ echo "--- Qdrant Setup (running as $(whoami)) ---"
114
+ QDRANT_CONFIG_DIR="/qdrant/config"
115
+ QDRANT_STORAGE_PATH_IN_CONFIG="/qdrant/storage"
116
+ ln -sfn "$QDRANT_DATA_DIR" "$QDRANT_STORAGE_PATH_IN_CONFIG"
117
+
118
+ echo "Starting Qdrant (as n8nuser)..."
119
+ su - n8nuser -c "/usr/local/bin/qdrant --config-path '$QDRANT_CONFIG_DIR/config.yaml'" &
120
+ QDRANT_PID=$!
121
+ echo "Waiting for Qdrant to start (PID: $QDRANT_PID)..."
122
+ until curl -sf http://localhost:6333/readyz > /dev/null; do
123
+ echo -n "."
124
+ sleep 1
125
+ if ! ps -p $QDRANT_PID > /dev/null; then echo "Qdrant process died."; exit 1; fi
126
+ done
127
+ echo "Qdrant started."
128
+
129
+ # --- Ollama Start (as n8nuser) ---
130
+ # (This section remains the same)
131
+ echo "--- Ollama Setup (running as $(whoami)) ---"
132
+ echo "Ollama models will be stored in: $OLLAMA_MODELS_DIR"
133
+
134
+ echo "Starting Ollama server (as n8nuser)..."
135
+ su - n8nuser -c "ollama serve" &
136
+ OLLAMA_PID=$!
137
+ echo "Waiting for Ollama to start (PID: $OLLAMA_PID)..."
138
+ until curl -sf http://localhost:11434/api/tags > /dev/null 2>&1 ; do
139
+ echo -n "."
140
+ sleep 1
141
+ if ! ps -p $OLLAMA_PID > /dev/null; then echo "Ollama process died."; exit 1; fi
142
+ done
143
+ echo "Ollama started."
144
+
145
+ # --- Supabase PostgreSQL Configuration ---
146
+ export SUPABASE_URL="https://wyohprbjfxgrxlrrvnhh.supabase.co"
147
+ export SUPABASE_KEY="sb_publishable_rxpUncZDI55WgW8F9F3log_Ea05sjxl"
148
+ export DBPOSTGRESDB_HOST="db.wyohprbjfxgrxlrrvnhh.supabase.co"
149
+ export DBPOSTGRESDB_PORT="5432"
150
+ export DBPOSTGRESDB_USER="postgres"
151
+ export DBPOSTGRESDB_DATABASE="postgres"
152
+ export DBPOSTGRESDB_PASSWORD="CHANGE_ME_SET_YOUR_SUPABASE_PASSWORD"
153
+
154
+ DEFAULT_MODEL="${DEFAULT_OLLAMA_MODEL:-llama3.1:8b}"
155
+ echo "Checking for default Ollama model: $DEFAULT_MODEL"
156
+ if ! ollama show "$DEFAULT_MODEL" > /dev/null 2>&1; then
157
+ echo "Pulling $DEFAULT_MODEL... This may take a while."
158
+ ollama pull "$DEFAULT_MODEL"
159
+ if [ $? -ne 0 ]; then echo "Warning: Failed to pull $DEFAULT_MODEL"; else echo "$DEFAULT_MODEL pulled."; fi
160
+ else
161
+ echo "$DEFAULT_MODEL already present."
162
+ fi
163
+
164
+ # --- n8n Start (as n8nuser) ---
165
+ echo "--- n8n Setup (running as $(whoami)) ---"
166
+
167
+ if [ -z "$N8N_ENCRYPTION_KEY" ]; then
168
+ echo "ERROR: N8N_ENCRYPTION_KEY is not set. Please set it as a Space secret."
169
+ exit 1
170
+ fi
171
+ if [ -z "$DB_POSTGRESDB_PASSWORD" ]; then
172
+ echo "ERROR: DB_POSTGRESDB_PASSWORD is not set. Please set it as a Space secret."
173
+ exit 1
174
+ fi
175
+
176
+ export N8N_USER_FOLDER="/home/n8nuser/.n8n"
177
+ export GENAI_MODELS_N8N_DEFAULT_MODEL="$DEFAULT_MODEL"
178
+ export DB_POSTGRESDB_PORT="$POSTGRES_PORT"
179
+
180
+ # URLs are already set in Dockerfile ENV, but we can override if needed
181
+ echo "N8N URLs configured:"
182
+ echo " N8N_EDITOR_BASE_URL: $N8N_EDITOR_BASE_URL"
183
+ echo " WEBHOOK_URL: $WEBHOOK_URL"
184
+ echo " N8N_HOST: $N8N_HOST"
185
+ echo " N8N_PORT: $N8N_PORT"
186
+ echo " N8N_PROTOCOL: $N8N_PROTOCOL"
187
+
188
+ # OAuth callback configuration for ClickUp compatibility
189
+ # n8n's OAuth callback URL is constructed from WEBHOOK_URL + /rest/oauth2-credential/callback
190
+ # ClickUp trims the path, so we need to ensure the base URL is correctly configured
191
+ # In ClickUp's app settings, register: https://leon4gr45-n8n.hf.space/
192
+ # n8n will automatically handle the full callback path internally
193
+
194
+ # Optional: Increase n8n log level for more startup details
195
+ # export N8N_LOG_LEVEL="debug"
196
+
197
+ echo "Before su: environment variables"
198
+ env | grep N8N
199
+
200
+ echo "Starting n8n (as n8nuser) with highly permissive (INSECURE) embedding rules for diagnosis..."
201
+ su n8nuser -c "echo 'Inside su:' && env | grep N8N && n8n start"
on_startup.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Write some commands here that will run on root user before startup.
3
+ # For example, to clone transformers and install it in dev mode:
4
+ # git clone https://github.com/huggingface/transformers.git
5
+ # cd transformers && pip install -e ".[dev]"
opencode.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "https://opencode.ai/config.json",
3
+ "model": "alias-code",
4
+ "provider": {
5
+ "blablador": {
6
+ "npm": "@ai-sdk/openai-compatible",
7
+ "name": "Blablador",
8
+ "options": {
9
+ "baseURL": "https://api.helmholtz-blablador.fz-juelich.de/v1"
10
+ },
11
+ "models": {
12
+ "alias-code": {
13
+ "name": "Code Model"
14
+ }
15
+ }
16
+ }
17
+ }
18
+ }
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ tree
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ jupyterlab==4.2.5
2
+ tornado==6.2
3
+ ipywidgets
start_server.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
3
+
4
+ NOTEBOOK_DIR="/data"
5
+
6
+ jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
7
+
8
+ jupyter-lab \
9
+ --ip 0.0.0.0 \
10
+ --port 7860 \
11
+ --no-browser \
12
+ --allow-root \
13
+ --ServerApp.token="$JUPYTER_TOKEN" \
14
+ --ServerApp.tornado_settings="{'headers': {'Content-Security-Policy': 'frame-ancestors *'}}" \
15
+ --ServerApp.cookie_options="{'SameSite': 'None', 'Secure': True}" \
16
+ --ServerApp.disable_check_xsrf=True \
17
+ --LabApp.news_url=None \
18
+ --LabApp.check_for_updates_class="jupyterlab.NeverCheckForUpdate" \
19
+ --notebook-dir=$NOTEBOOK_DIR