diff options
author | 2021-12-16 12:18:16 +0000 | |
---|---|---|
committer | 2021-12-16 16:59:22 +0000 | |
commit | 0ebd97a93b60035628834bc007c133f399413115 (patch) | |
tree | b2dbe02d4486683008bcf2e5650012251fa4e50f | |
parent | Explain how to configure extension within README (diff) |
Add pg_repack
This also includes a reformat of the README to make it easier to follow.
-rw-r--r-- | Dockerfile | 31 | ||||
-rw-r--r-- | README.md | 30 |
2 files changed, 47 insertions, 14 deletions
@@ -1,20 +1,33 @@ FROM postgres:14-alpine -ENV PG_CRON_VERSION 1.4.1 +ENV PG_CRON_VERSION=1.4.1 \ + PG_REPACK_VERSION=1.4.7 -# Download, build & install pg_cron -RUN apk add --no-cache --virtual .build-deps \ - cmake build-base wget postgresql-dev && \ - mkdir /build && \ - cd /build && \ +# Install build deps +RUN apk add --no-cache --virtual .build-deps cmake build-base wget postgresql-dev lz4-dev zlib-dev gawk + +#Download, build & install pg_cron +RUN mkdir /cron_build && \ + cd /cron_build && \ wget https://github.com/citusdata/pg_cron/archive/v$PG_CRON_VERSION.tar.gz && \ tar xzvf v$PG_CRON_VERSION.tar.gz && \ cd pg_cron-$PG_CRON_VERSION && \ make && \ - make install && \ + make install + +#Download, build & install pg_repack +RUN mkdir /repack_build && \ + cd /repack_build && \ + wget https://api.pgxn.org/dist/pg_repack/$PG_REPACK_VERSION/pg_repack-$PG_REPACK_VERSION.zip && \ + unzip pg_repack-$PG_REPACK_VERSION.zip && \ + cd pg_repack-$PG_REPACK_VERSION && \ + make && \ + make install + # Clean up: - cd / && \ - rm -rf /build && \ +RUN cd / && \ + rm -rf /cron_build && \ + rm -rf /repack_build && \ apk del .build-deps COPY ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh @@ -1,12 +1,25 @@ -# PostgreSQL + pg_cron +# PostgreSQL Extended -Dockerfile for building Postgres with the [pg_cron](https://github.com/citusdata/pg_cron) extension from citrusdata. +## Summary + +This repo contains the Dockerfile and supplementary files for building a Postgres image including some useful extensions + +### Extensions installed: + +- [pg_cron](https://github.com/citusdata/pg_cron) +- [pg_repack](https://github.com/reorg/pg_repack) + +## Details This image is derived from official [postgres:14-alpine](https://hub.docker.com/_/postgres) docker image. [docker-entrypint.sh](docker-entrypoint.sh) is directly from [docker-library](https://github.com/docker-library/postgres/blob/master/14/alpine/docker-entrypoint.sh). -A pre-build image of this Dockerfile is available from GHCR [here](https://github.com/ChrisLovering/psql_pg_cron/pkgs/container/psql_pg_cron). +A pre-built image is available from GHCR [here](https://github.com/ChrisLovering/psql_pg_cron/pkgs/container/psql_pg_cron). + -Once deployed, you nned to add the following to the bottom of your postgresql.conf file, replacing `my_database` with the name of the database you want pg_cron to be used in, making sure to reboot postgres after doing so. +## Post deployment steps + +### pg_cron +Add the following to the bottom of your postgresql.conf file, replacing `my_database` with the name of the database to make pg_cron available in, making sure to reboot postgres after doing so. This can't be done within this base image itself, as that would stop it from working within docker-compose. @@ -18,5 +31,12 @@ cron.database_name = 'my_database' You can then enable the pg_cron extension on that database by running the following within that database. ```sql -CREATE EXTENSION pg_cron +CREATE EXTENSION pg_cron; +``` + +### pg_repack +Run the following on the database you want pg_repack to be available in. + +```sql +CREATE EXTENSION pg_repack; ``` |