将plpython3 Extension添加到Postgres / timescaledb Alpine Docker Image

时间:2018-03-20 08:26:55

标签: postgresql docker alpine plpython 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

当我尝试创建扩展时,我收到以下错误:

postgres=# CREATE EXTENSION plpython3u;
ERROR:  could not open extension control file "/usr/local/share/postgresql/extension/plpython3u.control": No such file or directory

但是当我搜索容器内的文件时,我可以在不同的目录中找到它们:

/ # 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

如何将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

更新2

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

这导致了我希望找到答案的问题。如何将postgresql-plpython3安装到/usr/local/...而不是/usr/...

1 个答案:

答案 0 :(得分:2)

我可以肯定的是,如果您使用预构建的软件包,则会陷入硬编码的安装路径。

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

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
相关问题