diff --git a/Dockerfile.backend b/Dockerfile.backend index 0e9b2e9..befe60f 100644 --- a/Dockerfile.backend +++ b/Dockerfile.backend @@ -1,4 +1,5 @@ -FROM ubuntu:22.04 +FROM --platform=linux/amd64 ubuntu:22.04 +ARG DEBIAN_FRONTEND=noninteractive WORKDIR /app @@ -12,13 +13,15 @@ RUN apt-get update && apt-get install -y \ python3-pip \ python3-wheel \ build-essential \ - # Chrome dependencies - comprehensive list fonts-liberation \ + libasound-dev \ libasound2 \ + portaudio19-dev \ libatk-bridge2.0-0 \ libdrm2 \ libxcomposite1 \ libxdamage1 \ + libfontconfig1 \ libxrandr2 \ libgbm1 \ libxss1 \ @@ -61,22 +64,26 @@ COPY .env . COPY config.ini . # Install Chrome and ChromeDriver from chrome-for-testing -RUN wget -O chrome-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/136.0.7103.113/linux64/chrome-linux64.zip && \ - wget -O chromedriver-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/136.0.7103.113/linux64/chromedriver-linux64.zip && \ - unzip chrome-linux64.zip && \ +RUN wget -O chrome-headless-shell-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.55/linux64/chrome-headless-shell-linux64.zip && \ + wget -O chromedriver-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.55/linux64/chromedriver-linux64.zip && \ + unzip chrome-headless-shell-linux64.zip && \ unzip chromedriver-linux64.zip && \ mkdir -p /opt/google && \ ls -la && \ - mv chrome-linux64 /opt/google/chrome && \ + mv chrome-headless-shell-linux64 /opt/google/chrome && \ mv chromedriver-linux64/chromedriver /usr/local/bin/chromedriver && \ - chmod +x /opt/google/chrome/chrome && \ + chmod +x /opt/google/chrome/chrome-headless-shell && \ chmod +x /usr/local/bin/chromedriver RUN ln -s /opt/google/chrome/chrome /usr/local/bin/chrome -# Verify Chrome and ChromeDriver installation -RUN google-chrome --version -RUN chromedriver --version > /dev/null 2>&1 +# Debug ChromeDriver +RUN echo "=== ChromeDriver Debug ===" && \ + /usr/local/bin/chromedriver --version && \ + echo "Chrome binary:" && \ + /opt/google/chrome/chrome --version && \ + echo "Testing ChromeDriver startup:" && \ + timeout 5 /usr/local/bin/chromedriver --port=9999 || echo "ChromeDriver failed to start" ENV CHROME_BIN=/opt/google/chrome/chrome ENV CHROMEDRIVER_PATH=/usr/local/bin/chromedriver diff --git a/docker-compose.yml b/docker-compose.yml index 824d869..3360e8e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,7 +34,7 @@ services: - ./searxng:/etc/searxng:rw environment: - SEARXNG_BASE_URL=${SEARXNG_BASE_URL:-http://localhost:8080/} - - SEARXNG_SECRET_KEY=$(openssl rand -hex 32) + - SEARXNG_SECRET_KEY=${SEARXNG_SECRET_KEY} - UWSGI_WORKERS=4 - UWSGI_THREADS=4 cap_add: diff --git a/sources/browser.py b/sources/browser.py index f3ebad4..496cfdb 100644 --- a/sources/browser.py +++ b/sources/browser.py @@ -46,8 +46,9 @@ def get_chrome_path() -> str: "/usr/bin/chromium-browser", "/usr/bin/chromium", "/opt/chrome/chrome", - "opt/google/chrome/chrome", "/usr/local/bin/chrome", + "/opt/google/chrome/chrome-headless-shell", + "/opt/google/chrome/chrome", #"/app/chrome_bundle/chrome136/chrome-linux64" ] @@ -84,6 +85,7 @@ def install_chromedriver() -> str: # if os.path.exists("/app/chrome_bundle/chrome136/chromedriver"): # print("Using bundled ChromeDriver from /app/chrome_bundle/chrome136/chromedriver") # chromedriver_path = "/app/chrome_bundle/chrome136/chromedriver" + print("path:", chromedriver_path) if not chromedriver_path: try: print("ChromeDriver not found, attempting to install automatically...") @@ -132,7 +134,8 @@ def create_driver(headless=False, stealth_mode=True, crx_path="./crx/nopecha.crx chrome_options.binary_location = chrome_path if headless: - chrome_options.add_argument("--headless") + #chrome_options.add_argument("--headless") + chrome_options.add_argument("--headless=new") chrome_options.add_argument("--disable-gpu") chrome_options.add_argument("--disable-webgl") user_data_dir = tempfile.mkdtemp() @@ -142,6 +145,14 @@ def create_driver(headless=False, stealth_mode=True, crx_path="./crx/nopecha.crx chrome_options.add_argument(f"--accept-lang={lang}-{lang.upper()},{lang};q=0.9") chrome_options.add_argument("--timezone=Europe/Paris") chrome_options.add_argument("--no-sandbox") + chrome_options.add_argument('--disable-dev-shm-usage') + chrome_options.add_argument('--remote-debugging-port=9222') + chrome_options.add_argument('--disable-extensions') + chrome_options.add_argument('--disable-background-timer-throttling') + chrome_options.add_argument('--disable-backgrounding-occluded-windows') + chrome_options.add_argument('--disable-renderer-backgrounding') + chrome_options.add_argument('--disable-features=TranslateUI') + chrome_options.add_argument('--disable-ipc-flooding-protection') chrome_options.add_argument("--disable-dev-shm-usage") chrome_options.add_argument("--mute-audio") chrome_options.add_argument("--disable-notifications") diff --git a/start_services.sh b/start_services.sh index 07fcbb0..d9cc98c 100755 --- a/start_services.sh +++ b/start_services.sh @@ -96,6 +96,9 @@ sleep 4 docker stop $(docker ps -a -q) echo "All containers stopped" +# export searxng secret key +export SEARXNG_SECRET_KEY=$(openssl rand -hex 32) + if [ "$1" = "full" ]; then # First start backend and wait for it to be healthy echo "Full docker deployement. Starting backend service..."