From cfd939318495821485c7b3bcc59c293afb29d94a Mon Sep 17 00:00:00 2001 From: matevip Date: Fri, 24 Apr 2026 23:25:03 +0800 Subject: [PATCH] fix(docker): bake searxng settings.yml into custom image --- docker-compose.yml | 17 ++++------- docker/searxng/Dockerfile | 9 ++++++ docker/searxng/settings.yml | 61 +++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 docker/searxng/Dockerfile create mode 100644 docker/searxng/settings.yml diff --git a/docker-compose.yml b/docker-compose.yml index 82481181..b9ce2daf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,12 +33,13 @@ services: # SearXNG 搜索引擎(keyless 搜索 provider) # - # ⚠️ deploy/searxng/settings.yml is bind-mounted because the upstream image - # ships with JSON format disabled and the anti-bot Limiter plugin enabled — - # both of which would silently break mateclaw's SearXNGSearchProvider. - # Do NOT remove that bind mount. + # The custom image at docker/searxng/ bakes in settings.yml so the sidecar + # works out of the box (upstream image ships JSON disabled + Limiter enabled, + # both of which silently break mateclaw's SearXNGSearchProvider). + # No host bind-mount — edit docker/searxng/settings.yml and rebuild. searxng: - image: searxng/searxng:latest + build: + context: ./docker/searxng container_name: mateclaw-searxng restart: unless-stopped environment: @@ -46,11 +47,6 @@ services: - SEARXNG_SECRET=${SEARXNG_SECRET:-mateclaw-dev-searxng-secret-change-me} - UWSGI_WORKERS=2 - UWSGI_THREADS=4 - volumes: - - searxng_data:/etc/searxng - # This override MUST be mounted AFTER the named volume so it shadows - # the image's default settings.yml (enables JSON, disables limiter). - - ./deploy/searxng/settings.yml:/etc/searxng/settings.yml:ro ports: - "8088:8080" healthcheck: @@ -103,4 +99,3 @@ services: volumes: mysql_data: server_data: - searxng_data: diff --git a/docker/searxng/Dockerfile b/docker/searxng/Dockerfile new file mode 100644 index 00000000..a5dbc4ad --- /dev/null +++ b/docker/searxng/Dockerfile @@ -0,0 +1,9 @@ +# Custom SearXNG image for MateClaw. +# +# Bakes our settings.yml into /etc/searxng/settings.yml so the sidecar works +# out of the box with no host bind-mount. The upstream image ships JSON output +# disabled and the Limiter plugin enabled — both silently break mateclaw's +# SearXNGSearchProvider, so this override is required. +FROM searxng/searxng:latest + +COPY settings.yml /etc/searxng/settings.yml diff --git a/docker/searxng/settings.yml b/docker/searxng/settings.yml new file mode 100644 index 00000000..f159258b --- /dev/null +++ b/docker/searxng/settings.yml @@ -0,0 +1,61 @@ +# SearXNG config for MateClaw's bundled search sidecar. +# +# Two things differ from the upstream default: +# 1. JSON output format is enabled — mateclaw's SearXNGSearchProvider +# queries /search?format=json and fails silently without this. +# 2. The anti-bot Limiter plugin is disabled — it otherwise rejects +# server-side HTTP calls (no JS, no cookies) with HTTP 429. +# +# This file is baked into the custom image via docker/searxng/Dockerfile — +# do NOT bind-mount it from the host (prior host bind-mount broke deploys +# where the host directory did not exist and Docker auto-created an empty +# dir over the path). +# +# See https://docs.searxng.org/admin/settings/ for all knobs. + +use_default_settings: true + +general: + # Cosmetic only; shown in the UI title. + instance_name: "MateClaw Search" + # Keep this private — no outbound metrics. + donation_url: false + contact_url: false + enable_metrics: false + +search: + safe_search: 0 + autocomplete: "" + default_lang: "auto" + formats: + - html + - json # REQUIRED for mateclaw integration + +server: + # Override the default dev secret; docker-compose passes SEARXNG_SECRET in. + secret_key: "${SEARXNG_SECRET:-please-change-me-to-a-random-32-char-string}" + # Trust Docker's internal network — the reverse-proxy / rate-limit plugin + # uses this to know the caller's real IP. + limiter: false + image_proxy: false + # Bind address matches the container default. + bind_address: "0.0.0.0" + port: 8080 + +ui: + static_use_hash: true + +# The default engine list is huge; keep a tight set of reliable ones. +engines: + - name: duckduckgo + disabled: false + - name: bing + disabled: false + - name: brave + disabled: false + - name: wikipedia + disabled: false + - name: google + disabled: false + - name: startpage + disabled: false