From 1fe986e96cb8f84cf4af8beabfebabacd3729306 Mon Sep 17 00:00:00 2001 From: mavis Date: Mon, 15 Jun 2026 18:51:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(postgres):=20scws=20=E9=9C=80=E5=85=88=20./?= =?UTF-8?q?acprep=20=E7=94=9F=E6=88=90=20configure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Dockerfile.postgres | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/backend/Dockerfile.postgres b/backend/Dockerfile.postgres index f3491f1..5a5a8bf 100644 --- a/backend/Dockerfile.postgres +++ b/backend/Dockerfile.postgres @@ -1,32 +1,38 @@ FROM postgres:16-bookworm # zhparser 中文分词扩展 — 全源码编译 -# Debian / PGDG 仓库里都没有现成的 postgresql-16-zhparser / libscws-dev 包, -# 必须从 GitHub 拉源码自己 make +# Debian / PGDG 仓库里都没有 postgresql-16-zhparser / libscws-dev / scws 包, +# 必须从 GitHub 拉源码自己 make。 # # 步骤: -# 1) 装编译工具 + PG dev headers -# 2) 编译装 scws(https://github.com/hightman/scws,zhparser 依赖的分词库) -# 3) 编译装 zhparser(https://github.com/zhparser/zhparser) +# 1) 装编译工具链 + PG dev headers +# 2) 编译 scws(autotools 项目,先 ./acprep 生成 configure) +# 3) 编译 zhparser(PGXS 扩展,直接 make) # # build 时间:~3-5 分钟 -# 产物:/usr/lib/postgresql/16/lib/zhparser.so + libscws.so +# 产物:/usr/lib/postgresql/16/lib/zhparser.so + /usr/lib/libscws.so RUN set -eux; \ - # 1) 编译工具链 + # 1) 编译工具 + PG dev headers apt-get update; \ apt-get install -y --no-install-recommends \ build-essential \ git \ ca-certificates \ + # autotools(scws 依赖) + autoconf \ + automake \ + libtool \ + # pg_config / pgxs(编译 PG 扩展用) postgresql-server-dev-16; \ rm -rf /var/lib/apt/lists/* -# 2) 编译 scws(中文分词库) +# 2) 编译装 scws(autotools:先 ./acprep 生成 configure,再 ./configure && make) RUN set -eux; \ cd /tmp; \ git clone --depth 1 https://github.com/hightman/scws.git; \ cd scws; \ + ./acprep; \ ./configure --prefix=/usr; \ make -j$(nproc); \ make install; \ @@ -34,12 +40,11 @@ RUN set -eux; \ cd /; \ rm -rf /tmp/scws -# 3) 编译 zhparser +# 3) 编译装 zhparser(PGXS 扩展,直接 make) RUN set -eux; \ cd /tmp; \ git clone --depth 1 https://github.com/zhparser/zhparser.git; \ cd zhparser; \ - # PG_CONFIG 在 PATH 上(装 postgresql-server-dev-16 自带) make -j$(nproc); \ make install; \ cd /; \