From ad9ca5e7cb69361cef88e9376655696e5bc3a99c Mon Sep 17 00:00:00 2001 From: martin legrand Date: Thu, 17 Apr 2025 18:59:13 +0200 Subject: [PATCH] commented out backend service until solution found for chrome in docker problem --- Dockerfile.backend | 42 +++++++++------- docker-compose.yml | 68 +++++++++++--------------- frontend/agentic-seek-front/src/App.js | 2 +- sources/browser.py | 2 +- sources/llm_provider.py | 6 +-- 5 files changed, 58 insertions(+), 62 deletions(-) diff --git a/Dockerfile.backend b/Dockerfile.backend index 97906b0..1cb8149 100644 --- a/Dockerfile.backend +++ b/Dockerfile.backend @@ -1,24 +1,32 @@ -FROM python:3.10 +FROM ubuntu:22.04 +# Warning: doesn't work yet, backend is run on host machine for now WORKDIR /app -# Install system dependencies -RUN apt-get update && apt-get install -y \ - gcc \ - g++ \ - gfortran \ - libportaudio2 \ - portaudio19-dev \ - ffmpeg \ - libavcodec-dev \ - libavformat-dev \ - libavutil-dev \ - chromium \ - chromium-driver \ - && rm -rf /var/lib/apt/lists/* - -RUN pip cache purge +RUN apt-get update -qq -y && \ +apt-get install -y \ + gcc \ + g++ \ + gfortran \ + libportaudio2 \ + portaudio19-dev \ + ffmpeg \ + libavcodec-dev \ + libavformat-dev \ + libavutil-dev \ + gnupg2 \ + wget \ + unzip \ + python3 \ + python3-pip \ + libasound2 \ + libatk-bridge2.0-0 \ + libgtk-4-1 \ + libnss3 \ + xdg-utils \ + wget && \ +RUN chmod +x /opt/chrome/chrome # Install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt diff --git a/docker-compose.yml b/docker-compose.yml index b1e2df9..2f78cb9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -66,46 +66,36 @@ services: networks: - agentic-seek-net - backend: - container_name: backend - build: - context: ./ - dockerfile: Dockerfile.backend - stdin_open: true - tty: true - shm_size: 6g - ports: - - "8000:8000" - volumes: - - ./:/app - #network_mode: host - environment: - - NODE_ENV=development - - REDIS_URL=redis://redis:6379/0 - - SEARXNG_URL=http://searxng:8080 - - OLLAMA_URL=http://localhost:11434 - - LM_STUDIO_URL=http://localhost:1234 - extra_hosts: - - "host.docker.internal:host-gateway" - depends_on: - - redis - - searxng - - selenium - networks: - - agentic-seek-net - - selenium: - image: selenium/standalone-chrome - platform: linux/amd64 - shm_size: 2g - volumes: - - /dev/shm:/dev/shm - - chrome_profiles:/tmp/chrome - ports: - - 4444:4444 - networks: - - agentic-seek-net + # NOTE: backend service is not working yet due to issue with chromedriver on docker. + # Therefore backend is run on host machine. + # Open to pull requests to fix this. + #backend: + # container_name: backend + # build: + # context: ./ + # dockerfile: Dockerfile.backend + # stdin_open: true + # tty: true + # shm_size: 8g + # ports: + # - "8000:8000" + # volumes: + # - ./:/app + # environment: + # - NODE_ENV=development + # - REDIS_URL=redis://redis:6379/0 + # - SEARXNG_URL=http://searxng:8080 + # - OLLAMA_URL=http://localhost:11434 + # - LM_STUDIO_URL=http://localhost:1234 + # extra_hosts: + # - "host.docker.internal:host-gateway" + # depends_on: + # - redis + # - searxng + # networks: + # - agentic-seek-net + volumes: redis-data: chrome_profiles: diff --git a/frontend/agentic-seek-front/src/App.js b/frontend/agentic-seek-front/src/App.js index b5cb341..da4d043 100644 --- a/frontend/agentic-seek-front/src/App.js +++ b/frontend/agentic-seek-front/src/App.js @@ -122,7 +122,7 @@ function App() { const handleGetScreenshot = async () => { try { console.log('Fetching screenshot...'); - const res = await axios.get('http://0.0.0.0:8000/screenshots/updated_screen.png'); + const res = await axios.get('http://backend:8000/screenshots/updated_screen.png'); setResponseData((prev) => ({ ...prev, screenshot: res.data.screenshot })); setCurrentView('screenshot'); } catch (err) { diff --git a/sources/browser.py b/sources/browser.py index 677054c..0c3bfe0 100644 --- a/sources/browser.py +++ b/sources/browser.py @@ -39,7 +39,7 @@ def get_chrome_path() -> str: paths = ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta"] else: # Linux - paths = ["/usr/bin/google-chrome", "/usr/bin/chromium-browser", "/usr/bin/chromium"] + paths = ["/usr/bin/google-chrome", "/usr/bin/chromium-browser", "/usr/bin/chromium", "/opt/chrome/chrome", "/usr/local/bin/chrome"] for path in paths: if os.path.exists(path) and os.access(path, os.X_OK): # Check if executable diff --git a/sources/llm_provider.py b/sources/llm_provider.py index 1430d26..41540f5 100644 --- a/sources/llm_provider.py +++ b/sources/llm_provider.py @@ -53,10 +53,8 @@ class Provider: api_key_var = f"{provider.upper()}_API_KEY" api_key = os.getenv(api_key_var) if not api_key: - api_key = input(f"Please enter your {provider} API key: ") - set_key(".env", api_key_var, api_key) - self.logger.info("Set API key in env.") - load_dotenv() + pretty_print(f"API key {api_key_var} not found in .env file. Please add it", color="warning") + exit(1) return api_key def check_address_format(self, address):