diff --git a/examples/enable-extension/Dockerfile b/examples/enable-extension/Dockerfile new file mode 100644 index 00000000..3f46cf47 --- /dev/null +++ b/examples/enable-extension/Dockerfile @@ -0,0 +1,3 @@ +FROM registry.redhat.io/rhel8/postgresql-12 + +ADD . $APP_ROOT/src/ diff --git a/examples/enable-extension/README.md b/examples/enable-extension/README.md new file mode 100644 index 00000000..dd990fca --- /dev/null +++ b/examples/enable-extension/README.md @@ -0,0 +1,31 @@ +Extending PostgreSQL image by enabling extension +================================================ + +This is an example how to use the feature of extending the image (see more at https://github.com/sclorg/postgresql-container/tree/generated/12#extending-image) to enable extension `pg_stat_statements`. + +To use this in a Dockerfile, run: + +``` +podman build . -t my_postgresql:12 +``` + +Then, run the resulting image as usually: + +``` +podman run -d -e POSTGRESQL_ADMIN_PASSWORD=password my_postgresql:12 +``` + +And see the extension is enabled: +``` +podman exec -ti -l bash +bash-4.4$ psql +psql (12.1) +Type "help" for help. + +postgres=# \dx + List of installed extensions + Name | Version | Schema | Description +---------+---------+------------+------------------------------ + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language +(1 row) +``` diff --git a/examples/enable-extension/postgresql-cfg/s2i-extending.conf b/examples/enable-extension/postgresql-cfg/s2i-extending.conf new file mode 100644 index 00000000..b638d261 --- /dev/null +++ b/examples/enable-extension/postgresql-cfg/s2i-extending.conf @@ -0,0 +1 @@ +shared_preload_libraries='pg_stat_statements' diff --git a/examples/enable-extension/postgresql-init/set_passwords.sh b/examples/enable-extension/postgresql-init/set_passwords.sh new file mode 100644 index 00000000..05e210e7 --- /dev/null +++ b/examples/enable-extension/postgresql-init/set_passwords.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "CREATE EXTENSION pg_stat_statements;" | psql