Closed lukehutch closed 10 months ago
I'm trying to figure out how to take the basic postgres Docker image, and install a couple of extensions into that image,
A best practice is to extend the basic postgres docker image so that new extensions can be included.
For example, see the postgis/postgis
dockerfiles
@ImreSamu Thanks, I tried doing that, but I don't want to maintain or ship my own docker image, I would prefer to be able to use the postgres/postgres
docker image from Docker Hub, and simply extend it by specifying which extensions to install from pgxn
in my compose.yaml
file.
and simply extend it by specifying which extensions to install from pgxn in my compose.yaml file.
I'm not sure about your specific needs, but creating a universal pgxn Docker installation script (using --build_arg) that always works 100% is challenging. This is due to a few reasons based on my experience in trying to build a comprehensive postgres-postgis-geo-bundle image with additional pgxn libraries:
For instance, pgxn pg_bm25 requires an additional Rust development environment.
Also, for production environments, it's important to include all runtime dependencies in the Docker image for security auditing. Therefore, installing these during the runtime initialization phase is not advisable.
Many pgxn packages (like pgtap, h3, etc.) have pre-compiled versions for Debian PostgreSQL, which don't require extra development environments. It's preferable to use these if available.
FROM postgres:16
RUN set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-$PG_MAJOR-pgvector \
postgresql-$PG_MAJOR-h3 \
postgresql-$PG_MAJOR-hypopg \
postgresql-$PG_MAJOR-pgtap \
....
OK, thanks, that's helpful. I'll go ahead and close this then.
I'm trying to figure out how to take the basic
postgres
Docker image, and install a couple of extensions into that image, after the volume has been created. I don't see an easy way to do this incompose.yaml
, and if I try to runapt-get
or similar in/docker-entrypoint-initdb.d/init.sh
, it fails, because there is nosudo
command.Could you please add a way for the user to specify a list of extensions to install after the image has been created, maybe in an environment variable or something, so that the user can simply list extensions in
compose.yaml
?