Add plpython3 Extension to Postgres/timescaledb Alpine Docker Image

十年热恋 提交于 2020-12-29 09:57:47

问题


I try to add the plpython3 extension to my timescaledb/postgres (based on linux alpine) image:

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

When I try to create the extension I get the following error:

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

But when I search for the files inside my container I can find them within a different 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

How can I install postgresql-plpython3 to a different directory or configure postgres to recognize my added extension?

Update

When I just mv the files to /usr/local/share/postgresql/extension I get the error:

postgres=# CREATE EXTENSION plpython3u;
ERROR:  could not access file "$libdir/plpython3": No such file or directory

Update 2

So the issue with $libdir was that pg_config --pkglibdir points to /usr/local/lib/postgresql but plpython3.so is inside /usr/lib/postgresql. When I move everything to the according /usr/local directories I can successfully create the extension.

This leads to the question where I hope to find an answer. How can I install postgresql-plpython3 to /usr/local/... instead of /usr/...?


回答1:


I am fairly certain that if you use prebuilt packages you are stuck with hardcoded installation paths.

The easiest way around your problem is to create symlinks after installation:

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


来源:https://stackoverflow.com/questions/49379401/add-plpython3-extension-to-postgres-timescaledb-alpine-docker-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!