sclorg / postgresql-container

PostgreSQL container images based on Red Hat Software Collections and intended for OpenShift and general usage. Users can choose between Red Hat Enterprise Linux, Fedora, and CentOS based images.
http://softwarecollections.org
Apache License 2.0
164 stars 216 forks source link

WIP: Add 2 helpers for adding extension more easily #398

Closed mscherer closed 3 years ago

mscherer commented 3 years ago

This PR should go along #394, that as I as a basis to get postgis in postgresql.

I used that dockerfile:

FROM registry.fedoraproject.org/f33/postgresql
USER 0
RUN mkdir -p postgresql-cfg && echo "shared_preload_libraries='postgis-3'" > postgresql-cfg/postgis.conf
RUN mkdir -p postgresql-init && echo -en 'echo "CREATE EXTENSION IF NOT EXISTS postgis;" | psql' > postgresql-init/enable_postgis.sh
RUN dnf install --setopt=install_weak_deps=False --best -y postgis && dnf clean all
USER 26

However, with the addition of the 2 helpers, I think this could be simplified to be:

FROM postgres-fedora
USER 0
RUN dnf install --setopt=install_weak_deps=False --best -y postgis && dnf clean all
RUN load_pg_library postgis-3 
RUN create_extension postgis 
USER 26

This permit to hide implementation details, and avoid cut and paste (since postgis provides 4 extensions), and stupid errors (i took me a while to get a working container).

I marked the PR as WIP since there is no doc as I do not know where you would like to add it, and there is also no test (but I guess this can be done with pgaudit).

centos-ci commented 3 years ago

Can one of the admins verify this patch?

centos-ci commented 3 years ago

Can one of the admins verify this patch?

centos-ci commented 3 years ago

Can one of the admins verify this patch?

mscherer commented 3 years ago

So, upon further experimentaion, I think the part about creating the extension may not always work (as I need to create it per database, and I do not know enough of postgres if that's a good or bad idea). I guess we could add a 3rd hook for that (create in the database).

Is it safe to assume that the container will be used with 1 single database, and not shared accross multiple pod with multiple db ?

mscherer commented 3 years ago

Replaced by https://github.com/sclorg/postgresql-container/pull/399