历史条目的图标原先写死 fas fa-globe,整栏都是地球图标。 - 新增 history-server/favicon.go:后台抓取每个 host 的 favicon 并缓存到 data/item-icons/,命中后 conf.yml 写本地文件名,与手工图标同一套解析。 抓取顺序 <host>/favicon.ico → 首页 <link rel=icon>;3 个 worker, 失败 6 小时后再试;完成后合并触发一次 conf.yml 重建。 - 只缓存 Dashy 能渲染的格式:其 isImage() 白名单是 [svg,png,jpg], 写 .ico 进去完全渲染不出来。因此 .ico 先抽内嵌 PNG,若是传统 BMP/DIB 编码则解码后转 PNG(Google 这类站点只给老式 .ico)。 - 内网地址用 host:port 区分(不同端口的服务不再共用一个图标),且只直连; 外网站点直连失败时自动复用 SearXNG outgoing.proxies 的代理, 也可用 NAVI_FAVICON_PROXY 覆盖。 - 修掉一个真实缺陷:导航项都没有访问数据时,原来会提前 return 并把 「历史访问」清成只剩安装入口 —— 只浏览站外站点时真实历史会整个消失。 现在只冻结「常用服务」,历史照常生成。 - Dockerfile 去掉 # syntax=docker/dockerfile:1:该指令会让 BuildKit 去 pull docker/dockerfile 前端镜像,无外网环境直接构建失败;本文件未用 BuildKit 语法。 实测:6/6 站点(含 google.com 的 DIB 型 ico、github.com、docker.com、 news.ycombinator.com 与两个内网服务)均得到真实图标,页面 naturalWidth>0。
98 lines
3.8 KiB
Docker
98 lines
3.8 KiB
Docker
# 不用 `# syntax=docker/dockerfile:1`:该指令会让 BuildKit 去 pull
|
||
# docker/dockerfile 前端镜像,在无外网/仅代理的环境里会直接构建失败。
|
||
# 本文件未使用任何 BuildKit 专有语法,去掉后走内置前端即可。
|
||
|
||
# ── Stage 1: Go binaries ──
|
||
FROM golang:1.21-bookworm AS gobuild
|
||
|
||
WORKDIR /src/history
|
||
COPY history-server/ .
|
||
RUN GOPROXY=https://goproxy.cn,direct CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/history-server .
|
||
|
||
WORKDIR /src/admin
|
||
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 ──
|
||
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}
|
||
|
||
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
|
||
|
||
# ── Stage 3: browser extension packages ──
|
||
# 供 /extension/install.html 下载(Chromium 用 zip,Firefox 用 xpi)
|
||
FROM debian:bookworm-slim AS extpack
|
||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends zip ca-certificates \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
COPY extension/chrome /src/chrome
|
||
COPY extension/firefox /src/firefox
|
||
RUN cd /src/chrome && zip -qr /out/navi-chrome.zip . \
|
||
&& cd /src/firefox && zip -qr /out/navi-firefox.xpi .
|
||
|
||
# ── Stage 4: Runtime ──
|
||
FROM debian:bookworm-slim
|
||
|
||
ENV DEBIAN_FRONTEND=noninteractive
|
||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
nginx python3 supervisor curl ca-certificates git \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
# Copy SearXNG venv + source
|
||
COPY --from=searxng-build /opt/searxng-venv /app/searxng-venv
|
||
COPY --from=searxng-build /usr/lib/python3.11 /usr/lib/python3.11
|
||
COPY --from=searxng-build /lib/x86_64-linux-gnu /lib/x86_64-linux-gnu
|
||
COPY --from=searxng-build /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
|
||
|
||
# Dashy static files
|
||
COPY --from=lissy93/dashy:latest /app/dist /app/dashy
|
||
|
||
# Go binaries
|
||
COPY --from=gobuild /out/history-server /usr/local/bin/history-server
|
||
COPY --from=gobuild /out/admin-server /usr/local/bin/admin-server
|
||
|
||
# Config files
|
||
COPY nginx.conf /etc/nginx/nginx.conf
|
||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||
COPY searxng-settings.yml /etc/searxng/settings.yml
|
||
COPY conf.example.yml /app/defaults/conf.yml
|
||
COPY admin/index.html /app/admin/index.html
|
||
|
||
# 浏览器扩展安装页与安装包(通过 /extension/ 访问)
|
||
COPY web/extension/install.html /app/dashy/extension/install.html
|
||
COPY --from=extpack /out/navi-chrome.zip /app/dashy/extension/navi-chrome.zip
|
||
COPY --from=extpack /out/navi-firefox.xpi /app/dashy/extension/navi-firefox.xpi
|
||
|
||
# Inject search script into Dashy
|
||
COPY web/navi.js /app/dashy/navi.js
|
||
RUN sed -i 's#</body>#<script src="/navi.js"></script></body>#' /app/dashy/index.html
|
||
|
||
# Data directory
|
||
RUN mkdir -p /app/data/item-icons /var/log/supervisor /var/cache/searxng /run/nginx
|
||
|
||
VOLUME ["/app/data"]
|
||
EXPOSE 8080
|
||
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
||
CMD curl -fs http://localhost:8080/conf.yml || exit 1
|
||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|