diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d2f72db --- /dev/null +++ b/.dockerignore @@ -0,0 +1,33 @@ +!*.go +!go.mod +!go.sum +!*.py +!*.js +!*.html +!*.yml +!*.yaml +!*.conf +!Dockerfile +!docker-compose.yml +!nginx.conf +!supervisord.conf +!searxng-settings.yml +!conf.yml +!conf.example.yml +!.env.example +!web/ +!admin/ +!admin-server/ +!gateway/ +!history-server/ +!extension/ +!docker/ +!build.sh +!README.md +.git +.gitignore +codegraph* +*.tar +*.tar.gz +*.img +*.hmap diff --git a/Dockerfile b/Dockerfile index b96e6a4..fbff0d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,14 +12,13 @@ COPY admin-server/ . RUN GOPROXY=https://goproxy.cn,direct go mod tidy && CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/admin-server . # ── Stage 2: SearXNG from source ── +# Build args for proxy (passed at build time) +ARG HTTP_PROXY="" +ARG HTTPS_PROXY="" + FROM debian:bookworm-slim AS searxng-build -ARG HTTP_PROXY=http://172.17.0.1:7890 -ARG HTTPS_PROXY=http://172.17.0.1:7890 - ENV DEBIAN_FRONTEND=noninteractive -ENV http_proxy=${HTTP_PROXY} -ENV https_proxy=${HTTPS_PROXY} ENV HTTP_PROXY=${HTTP_PROXY} ENV HTTPS_PROXY=${HTTPS_PROXY} @@ -27,13 +26,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ python3 python3-pip python3-venv git ca-certificates \ && rm -rf /var/lib/apt/lists/* -RUN git clone --depth 1 https://github.com/searxng/searxng.git /src/searxng \ - && python3 -m venv /opt/searxng-venv \ - && /opt/searxng-venv/bin/pip install --upgrade pip setuptools wheel msgspec \ - && cd /src/searxng \ - && /opt/searxng-venv/bin/pip install --no-cache-dir -r requirements.txt \ - && /opt/searxng-venv/bin/pip install --no-cache-dir --no-build-isolation . \ - && rm -rf /src/searxng +# Install SearXNG dependencies with proxy support +# Using --retries and longer timeout for reliability +RUN python3 -m venv /opt/searxng-venv && \ + /opt/searxng-venv/bin/pip install --upgrade pip setuptools wheel && \ + /opt/searxng-venv/bin/pip install --retries 5 --timeout 120 \ + msgspec beautifulsoup4 lxml html5lib flask werkzeug gunicorn \ + pyyaml python-dateutil flask-babel psutil pygments pymdown-extensions \ + redis brotli brotli-ffi websocket-client httpx/setuptools && \ + /opt/searxng-venv/bin/pip install --no-build-isolation \ + "git+https://github.com/searxng/searxng.git@master" # ── Stage 3: Runtime ── FROM debian:bookworm-slim diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..8b072de --- /dev/null +++ b/build.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# Build script with large-context handling and proxy support +# Usage: ./build.sh [--proxy=http://host:port] [--clean] +set -euo pipefail + +PROXY="${HTTP_PROXY:-}" +CLEAN="${CLEAN:-false}" + +while [[ $# -gt 0 ]]; do + case $1 in + --proxy) PROXY="$2"; shift 2;; + --clean) CLEAN="true"; shift;; + *) echo "Unknown option: $1"; exit 1;; + esac +done + +# Large context: use --build-arg to pass proxy into build +BUILD_ARGS="" +if [[ -n "$PROXY" ]]; then + BUILD_ARGS="--build-arg HTTP_PROXY=$PROXY --build-arg HTTPS_PROXY=$PROXY --build-arg PIP_PROXY=$PROXY" +fi + +echo "=== Building with args: $BUILD_ARGS ===" + +docker build $BUILD_ARGS -t jianf-navi:latest \ + --build-arg CONTEXT_LIMIT=1000 \ + . + +if [[ "$CLEAN" == "true" ]]; then + echo "=== Cleaning old layers ===" + docker system prune -a --force --filter "label=jianf-navi" 2>/dev/null || true +fi + +echo "=== Push to Gitea (after testing) ===" +echo "Image: jianf-navi:latest" +echo "Size: $(docker images jianf-navi:latest --format '{{.Size}}')" +echo "Build done. Run 'docker push' when ready." diff --git a/history-server/main.go b/history-server/main.go index ba14618..48e6ba0 100644 --- a/history-server/main.go +++ b/history-server/main.go @@ -560,7 +560,7 @@ func main() { } // isCodeHostVal 判断导航项是否代码托管:只认知名托管 host 与标题关键词, -// 避免 "git." 子串误匹配域名中段(如 dify.example.com)。 +// 避免 "git." 子串误匹配域名中段(如 your-dify.example)。 func isCodeHostVal(title, host, url string) bool { lowT := strings.ToLower(title) if strings.Contains(lowT, "gitea") || strings.Contains(lowT, "github") || diff --git a/nginx.conf b/nginx.conf index 8b274cd..a2de710 100644 --- a/nginx.conf +++ b/nginx.conf @@ -25,9 +25,9 @@ http { index index.html; # ===== SearXNG 反向代理 ===== - # SearXNG 路由是 /search(无尾斜杠),/search/ 会 404,故统一 rewrite 去掉尾斜杠。 - # 结果页内静态资源/页面链接是绝对根路径(/static/、/preferences、/autocompleter 等)。 + # SearXNG 路由是 /search(无尾斜杠),/search/ 会 404,故 rewrite 去掉尾斜杠。 location ~ ^/search/?$ { + rewrite ^/search/?$ /search break; proxy_pass http://127.0.0.1:8888; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; diff --git a/searxng-settings.yml b/searxng-settings.yml index 499ca4b..e008168 100644 --- a/searxng-settings.yml +++ b/searxng-settings.yml @@ -1,15 +1,4 @@ -use_default_settings: - engines: - keep_only: - - google - - bing - - baidu - - sogou - - 360search - - wikipedia - - github - - stackoverflow - +use_default_settings: true general: instance_name: "JianF Search" debug: false @@ -34,42 +23,33 @@ outgoing: max_request_timeout: 4.0 pool_connections: 100 pool_maxsize: 20 - # SearXNG 的 curl_cffi 网络层只认这里配置的代理(不走环境变量 http_proxy)。 - # 需要代理出网(例如服务器在国内访问不了 Google/Bing)时,把地址换成你自己的代理: - # proxies: - # all://: http://:7890 + # SearXNG curl_cffi 只认这个配置(不走 http_proxy 环境变量) + # 需要代理出网时取消注释并填写你的代理地址 + # proxies: + # all://: http://your-proxy:7890 proxies: {} engines: - # 默认引擎列表里 google/bing 等是 disabled,需显式启用 - name: google - engine: google - shortcut: g disabled: false - name: bing - engine: bing - shortcut: b disabled: false - name: baidu - engine: baidu - shortcut: bd disabled: false - name: sogou - engine: sogou - shortcut: sg disabled: false - name: 360search - engine: 360search - shortcut: 360 disabled: false - name: wikipedia - engine: wikipedia - shortcut: wp disabled: false - name: github - engine: github - shortcut: gh disabled: false - - name: stackoverflow - engine: stackoverflow - shortcut: st + - name: npm disabled: false + - name: pypi + disabled: false + - name: duckduckgo + disabled: true + - name: startpage + disabled: true + - name: brave + disabled: true