mirror of
https://github.com/n8n-io/self-hosted-ai-starter-kit.git
synced 2025-11-29 08:33:15 +00:00
updated setup, with working hooks
This commit is contained in:
@@ -1,17 +1,15 @@
|
|||||||
version: '3.8'
|
|
||||||
volumes:
|
volumes:
|
||||||
n8n_storage:
|
n8n_storage:
|
||||||
postgres_storage:
|
postgres_storage:
|
||||||
ollama_storage:
|
ollama_storage:
|
||||||
qdrant_storage:
|
qdrant_storage:
|
||||||
infinity_storage:
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
n8n:
|
demo:
|
||||||
|
|
||||||
x-n8n: &service-n8n
|
x-n8n: &service-n8n
|
||||||
image: n8nio/n8n:latest
|
image: n8nio/n8n:latest
|
||||||
networks: ['n8n']
|
networks: ['demo']
|
||||||
environment:
|
environment:
|
||||||
- DB_TYPE=postgresdb
|
- DB_TYPE=postgresdb
|
||||||
- DB_POSTGRESDB_HOST=postgres
|
- DB_POSTGRESDB_HOST=postgres
|
||||||
@@ -28,39 +26,17 @@ x-n8n: &service-n8n
|
|||||||
x-ollama: &service-ollama
|
x-ollama: &service-ollama
|
||||||
image: ollama/ollama:latest
|
image: ollama/ollama:latest
|
||||||
container_name: ollama
|
container_name: ollama
|
||||||
networks: ['n8n']
|
networks: ['demo']
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- 11434:11434
|
- 11434:11434
|
||||||
volumes:
|
volumes:
|
||||||
- ollama_storage:/root/.ollama
|
- ollama_storage:/root/.ollama
|
||||||
|
|
||||||
x-infinity: &service-infinity
|
|
||||||
image: michaelf34/infinity
|
|
||||||
container_name: infinity
|
|
||||||
networks: ['n8n']
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
- SENTENCE_TRANSFORMERS_HOME=/infinity
|
|
||||||
- MODEL_ID=BAAI/bge-small-en-v1.5
|
|
||||||
ports:
|
|
||||||
- 7997:7997
|
|
||||||
volumes:
|
|
||||||
- infinity_storage:/infinity
|
|
||||||
|
|
||||||
x-gpu-support: &deploy-gpu
|
|
||||||
resources:
|
|
||||||
reservations:
|
|
||||||
devices:
|
|
||||||
- driver: nvidia
|
|
||||||
count: 1
|
|
||||||
capabilities: [gpu]
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
container_name: postgres
|
networks: ['demo']
|
||||||
networks: ['n8n']
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER
|
- POSTGRES_USER
|
||||||
@@ -68,8 +44,6 @@ services:
|
|||||||
- POSTGRES_DB
|
- POSTGRES_DB
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_storage:/var/lib/postgresql/data
|
- postgres_storage:/var/lib/postgresql/data
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD-SHELL', 'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
|
test: ['CMD-SHELL', 'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
|
||||||
interval: 5s
|
interval: 5s
|
||||||
@@ -108,7 +82,7 @@ services:
|
|||||||
qdrant:
|
qdrant:
|
||||||
image: qdrant/qdrant
|
image: qdrant/qdrant
|
||||||
container_name: qdrant
|
container_name: qdrant
|
||||||
networks: ['n8n']
|
networks: ['demo']
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- 6333:6333
|
- 6333:6333
|
||||||
@@ -119,18 +93,13 @@ services:
|
|||||||
profiles: ["cpu"]
|
profiles: ["cpu"]
|
||||||
<<: *service-ollama
|
<<: *service-ollama
|
||||||
|
|
||||||
infinity-cpu:
|
|
||||||
profiles: ["cpu"]
|
|
||||||
<<: *service-infinity
|
|
||||||
|
|
||||||
ollama-gpu:
|
ollama-gpu:
|
||||||
profiles: ["gpu-nvidia"]
|
profiles: ["gpu-nvidia"]
|
||||||
<<: *service-ollama
|
<<: *service-ollama
|
||||||
deploy:
|
deploy:
|
||||||
<<: *deploy-gpu
|
resources:
|
||||||
|
reservations:
|
||||||
infinity-gpu:
|
devices:
|
||||||
profiles: ["gpu-nvidia"]
|
- driver: nvidia
|
||||||
<<: *service-infinity
|
count: 1
|
||||||
deploy:
|
capabilities: [gpu]
|
||||||
<<: *deploy-gpu
|
|
||||||
|
|||||||
12
n8n/hooks.js
12
n8n/hooks.js
@@ -5,7 +5,7 @@ const { dirname, resolve } = require("path");
|
|||||||
const Layer = require("express/lib/router/layer");
|
const Layer = require("express/lib/router/layer");
|
||||||
|
|
||||||
const n8nDir = dirname(require.resolve("n8n"));
|
const n8nDir = dirname(require.resolve("n8n"));
|
||||||
const jwtAuth = require(resolve(n8nDir, "auth/jwt"));
|
const { AuthService } = require(resolve(n8nDir, "auth/auth.service"));
|
||||||
|
|
||||||
async function disableUmHook({ app }, config) {
|
async function disableUmHook({ app }, config) {
|
||||||
await this.dbCollections.Settings.update(
|
await this.dbCollections.Settings.update(
|
||||||
@@ -21,17 +21,14 @@ async function disableUmHook({ app }, config) {
|
|||||||
|
|
||||||
owner.email = "demo@n8n.io";
|
owner.email = "demo@n8n.io";
|
||||||
owner.firstName = "Demo";
|
owner.firstName = "Demo";
|
||||||
owner.lastName = "McDemoFace";
|
owner.lastName = "User";
|
||||||
|
|
||||||
await this.dbCollections.User.save(owner);
|
await this.dbCollections.User.save(owner);
|
||||||
|
|
||||||
jwtAuth.resolveJwt = () => owner;
|
AuthService.prototype.resolveJwt = () => owner;
|
||||||
|
|
||||||
const { stack } = app._router;
|
const { stack } = app._router;
|
||||||
const index = stack.findIndex((l) => l.name === "cookieParser");
|
stack.unshift(
|
||||||
stack.splice(
|
|
||||||
index + 4,
|
|
||||||
3,
|
|
||||||
new Layer(
|
new Layer(
|
||||||
"/",
|
"/",
|
||||||
{
|
{
|
||||||
@@ -39,7 +36,6 @@ async function disableUmHook({ app }, config) {
|
|||||||
end: false,
|
end: false,
|
||||||
},
|
},
|
||||||
async (req, res, next) => {
|
async (req, res, next) => {
|
||||||
req.user = owner;
|
|
||||||
req.cookies = { "n8n-auth": "fake" };
|
req.cookies = { "n8n-auth": "fake" };
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user