From e7f9daab361296bf229dba89824e95cfff6c59c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 18 Jul 2024 15:12:22 +0200 Subject: [PATCH] updated setup, with working hooks --- docker-compose.yml | 53 ++++++++++------------------------------------ n8n/hooks.js | 12 ++++------- 2 files changed, 15 insertions(+), 50 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9041002..86aae96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,15 @@ -version: '3.8' volumes: n8n_storage: postgres_storage: ollama_storage: qdrant_storage: - infinity_storage: networks: - n8n: + demo: x-n8n: &service-n8n image: n8nio/n8n:latest - networks: ['n8n'] + networks: ['demo'] environment: - DB_TYPE=postgresdb - DB_POSTGRESDB_HOST=postgres @@ -28,39 +26,17 @@ x-n8n: &service-n8n x-ollama: &service-ollama image: ollama/ollama:latest container_name: ollama - networks: ['n8n'] + networks: ['demo'] restart: unless-stopped ports: - 11434:11434 volumes: - 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: postgres: image: postgres:16-alpine - container_name: postgres - networks: ['n8n'] + networks: ['demo'] restart: unless-stopped environment: - POSTGRES_USER @@ -68,8 +44,6 @@ services: - POSTGRES_DB volumes: - postgres_storage:/var/lib/postgresql/data - ports: - - 5432:5432 healthcheck: test: ['CMD-SHELL', 'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}'] interval: 5s @@ -108,7 +82,7 @@ services: qdrant: image: qdrant/qdrant container_name: qdrant - networks: ['n8n'] + networks: ['demo'] restart: unless-stopped ports: - 6333:6333 @@ -119,18 +93,13 @@ services: profiles: ["cpu"] <<: *service-ollama - infinity-cpu: - profiles: ["cpu"] - <<: *service-infinity - ollama-gpu: profiles: ["gpu-nvidia"] <<: *service-ollama deploy: - <<: *deploy-gpu - - infinity-gpu: - profiles: ["gpu-nvidia"] - <<: *service-infinity - deploy: - <<: *deploy-gpu + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] diff --git a/n8n/hooks.js b/n8n/hooks.js index 345ee57..2ff4025 100644 --- a/n8n/hooks.js +++ b/n8n/hooks.js @@ -5,7 +5,7 @@ const { dirname, resolve } = require("path"); const Layer = require("express/lib/router/layer"); 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) { await this.dbCollections.Settings.update( @@ -21,17 +21,14 @@ async function disableUmHook({ app }, config) { owner.email = "demo@n8n.io"; owner.firstName = "Demo"; - owner.lastName = "McDemoFace"; + owner.lastName = "User"; await this.dbCollections.User.save(owner); - jwtAuth.resolveJwt = () => owner; + AuthService.prototype.resolveJwt = () => owner; const { stack } = app._router; - const index = stack.findIndex((l) => l.name === "cookieParser"); - stack.splice( - index + 4, - 3, + stack.unshift( new Layer( "/", { @@ -39,7 +36,6 @@ async function disableUmHook({ app }, config) { end: false, }, async (req, res, next) => { - req.user = owner; req.cookies = { "n8n-auth": "fake" }; next(); }