将plpython3扩展添加到Postgres / timescaledb Alpine Docker Image

Yan*_*ann 6 postgresql plpython docker alpine-linux timescaledb

我尝试将plpython3扩展名添加到我的timescaledb/ postgres(基于Linux alpine)映像中:

FROM timescale/timescaledb:0.9.0-pg10

RUN set -ex \
    && apk add --no-cache --virtual .plpython3-deps --repository http://nl.alpinelinux.org/alpine/edge/testing \
    postgresql-plpython3
Run Code Online (Sandbox Code Playgroud)

当我尝试创建扩展名时,出现以下错误:

postgres=# CREATE EXTENSION plpython3u;
ERROR:  could not open extension control file "/usr/local/share/postgresql/extension/plpython3u.control": No such file or directory
Run Code Online (Sandbox Code Playgroud)

但是,当我在容器中搜索文件时,可以在其他目录中找到它们:

/ # find / -name '*plpy*'
/usr/lib/postgresql/plpython3.so
/usr/share/postgresql/extension/plpython3u.control
/usr/share/postgresql/extension/plpython3u--1.0.sql
/usr/share/postgresql/extension/plpython3u--unpackaged--1.0.sql
Run Code Online (Sandbox Code Playgroud)

如何安装postgresql-plpython3到其他目录或配置postgres为识别添加的扩展名?

更新资料

当我只是要发送mv的文件时,/usr/local/share/postgresql/extension出现错误:

postgres=# CREATE EXTENSION plpython3u;
ERROR:  could not access file "$libdir/plpython3": No such file or directory
Run Code Online (Sandbox Code Playgroud)

更新2

因此,问题$libdir在于pg_config --pkglibdir指向/usr/local/lib/postgresqlplpython3.so在内部/usr/lib/postgresql。当我将所有内容移动到相应/usr/local目录时,我可以成功创建扩展名。

这引出了我希望找到答案的问题。如何安装postgresql-plpython3/usr/local/...代替/usr/...

Kon*_*tor 7

我相当肯定,如果您使用预构建的软件包,您会遇到硬编码的安装路径。

解决问题的最简单方法是在安装后创建符号链接:

FROM timescale/timescaledb:0.9.0-pg10

RUN set -ex \
    && apk add --no-cache --virtual .plpython3-deps --repository http://nl.alpinelinux.org/alpine/edge/testing \
    postgresql-plpython3 \
    && ln -s /usr/lib/postgresql/plpython3.so /usr/local/lib/postgresql/plpython3.so \
    && ln -s /usr/share/postgresql/extension/plpython3u.control /usr/local/share/postgresql/extension/plpython3u.control \
    && ln -s /usr/share/postgresql/extension/plpython3u--1.0.sql /usr/local/share/postgresql/extension/plpython3u--1.0.sql \
    && ln -s /usr/share/postgresql/extension/plpython3u--unpackaged--1.0.sql /usr/local/share/postgresql/extension/plpython3u--unpackaged--1.0.sql
Run Code Online (Sandbox Code Playgroud)