docker-library / postgres

Docker Official Image packaging for Postgres
http://www.postgresql.org
MIT License
2.16k stars 1.13k forks source link

Is there an easy way to customize the image with new extensions (like using pgxn)? #1109

Closed turicas closed 1 year ago

turicas commented 1 year ago

Hi,

First of all, thanks for your great work. I'm using pg-vector, apacheage and other extensions in a project and to install all extensions I usually create a new Dockerfile based on this image and install using pgxn, like the code below. Since it's a very compliated step-by-step I'm wondering if is there any other easier/official way to do so (like having just a text file with extension names or passing env vars).

FROM postgres:15-bookworm

RUN apt update \
  && apt install -y build-essential pgxnclient postgresql-server-dev-15 \
  && apt upgrade -y \
  && pgxn install apacheage \
  && pgxn install vector \
  && apt remove -y build-essential pgxnclient postgresql-server-dev-15 \
  && apt autoremove -y \
  && apt purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
  && apt clean \
  && rm -rf /var/lib/apt/lists/*

Note: for some extensions I could also use postgres' APT repository to avoid compiling from source.

yosifkit commented 1 year ago

like having just a text file with extension names or passing env vars

We haven't added scripts to the image beyond what comes via postgres upstream packages (aside from the entrypoint) to add this sort of functionality. We try to focus on providing an image that represents upstream releases as close as possible; I don't think we want to add any other scripts as our current entrypoint script is already a large deviation from that goal.

turicas commented 1 year ago

Ok, thanks.