Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Official way to include extensions #340

Closed
gmile opened this issue Sep 16, 2017 · 5 comments
Closed

Official way to include extensions #340

gmile opened this issue Sep 16, 2017 · 5 comments

Comments

@gmile
Copy link

gmile commented Sep 16, 2017

What is the official way of adding postgres extensions, given postgres-alpine is a base image?

I tried to add postgresql-pglogical and postgis extensions by installing respective apk packages, but this process, despite being the most intuitive and straightforward, failed for me.

Here's my Dockerfile:

FROM postgres:9.6.4-alpine

RUN apk add --update --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ postgresql-pglogical postgis

Opening a now-closed issue in apline linux tracker made me realize that in a container above I ended up having two postgreses installed:

  • one coming from the base image,
  • one coming from the apk (apk has to make sure that for given packages to install all dependencies are met; for postgresql-pglogical and postgis package called postgres is a dependency).

I can see other issues asking for clarification around adding extensions:

Maybe it makes sense to include a statement in a readme? Something like:

For any postgres extension not listed in postgres-contrib, make sure to compile them in your own image.

@tianon
Copy link
Member

tianon commented Oct 4, 2017 via email

@tianon
Copy link
Member

tianon commented Apr 20, 2018

docker-library/docs#1204 👍

@62mkv
Copy link

62mkv commented Mar 18, 2020

would be cool to mention "official" way to activate already installed extensions; for example. I have to run CREATE EXTENSION "uuid-ossp"; every time I re-run the container with volume removal.

@luan-phamhuu
Copy link

Not any mean offcial but here is a working solution:

FROM postgres:12 AS extension_builder

# Already download extension code
RUN cd /
RUN mkdir external_extensions
RUN mkdir /external_extensions/sequential-uuids
COPY lib/sequential-uuids/ /external_extensions/sequential-uuids/
WORKDIR /external_extensions/sequential-uuids/

RUN apt-get update && apt install build-essential libicu-dev postgresql-server-dev-all -y --no-install-recommends
RUN make clean && make install

FROM postgres:12
# run find / -name 'sequential_uuids*' to find newly compiled files and copy to next stage
COPY --from=extension_builder /usr/lib/postgresql/12/lib /usr/lib/postgresql/12/lib
COPY --from=extension_builder /usr/share/postgresql/12/extension /usr/share/postgresql/12/extension

credit: https://www.reddit.com/r/docker/comments/ea70rz/why_did_adding_a_postgres_extension_to_the_base/

@yuuuxt
Copy link

yuuuxt commented Oct 23, 2020

based on @phluan 's work, here's the Dockerfiles I'm using: https://hub.docker.com/r/yuuuxt/postgres_seq_uuid/dockerfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants