What is the recommended approach to enable the plpython3u extension with a customized python3 environment in cloudnative-pg postgresql images? #4510
-
I have reviewed this post regarding the creation of custom postgresql container images for CloudNativePG. I have also seen #3672, where it is implied that others are using cloudnative-pg with the plpython3u extension. I understand one should not plan to update the python environment in the immutable default images. However, it is also clear that these images already include the installation of custom python libraries, barman in particular, as part of the build process. Would the most highly recommended approach to enabling and working with plpython3u with custom python dependencies be to
FROM ghcr.io/cloudnative-pg/postgresql:16.2-bookworm
USER root
COPY requirements.txt /
RUN set -xe; \
pip3 install --break-system-packages --no-deps -r requirements.txt;
USER 26 build/push docker build -t postgresql-plpython3u:16 .
docker push ghcr.io/userorg/postgresql-plpython3u:16 and, by analogy to the manner in which it is recommended to create PostGIS clusters, use something like the following to create a cloudnative-pg Cluster resource with plpython3u-enabled database(s) apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: plpython3u-cluster-example
spec:
instances: 3
imageName: ghcr.io/userorg/postgresql-plpython3u:16
bootstrap:
initdb:
postInitTemplateSQL:
- CREATE EXTENSION plpython3u;
storage:
size: 1Gi ... Or, is there another recommendation for working with cloudnative-pg clusters whose database(s) require(s) plpython3u postgresql functions? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hii Cameron, You've laid out two solid approaches for integrating the
Regarding creating a cluster resource with If neither of these approaches fully meets your needs, it would be a good idea to discuss this more in-depth with the community or check for additional recommendations directly with the maintainers of CloudNativePG. I hope this helps clarify your options! |
Beta Was this translation helpful? Give feedback.
-
Particularly, I believe the best approach in your case would be to build directly from a Dockerfile. Here's why I think this might suit your needs well:
|
Beta Was this translation helpful? Give feedback.
Particularly, I believe the best approach in your case would be to build directly from a Dockerfile. Here's why I think this might suit your needs well:
Simplicity and Speed: Building an image directly from a Dockerfile is a quick and straightforward way to add custom dependencies. This approach allows for rapid iterations and testing, which is ideal for agile development and deployment.
Lower Maintenance: Maintaining a fork of a repository can become complex over time, especially when trying to sync with upstream changes. Direct building via a Dockerfile minimizes maintenance efforts and keeps the process more manageable.
Flexibility: Using a Dockerfile allows for the flexibility t…