Skip to content

Commit

Permalink
Merge pull request sclorg#394 from hhorak/example-extension
Browse files Browse the repository at this point in the history
Add example how to enable extension
  • Loading branch information
phracek committed Oct 5, 2023
2 parents 9cd6c73 + ebc071a commit 62a947e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/enable-extension/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM registry.redhat.io/rhel8/postgresql-12

ADD . $APP_ROOT/src/
31 changes: 31 additions & 0 deletions examples/enable-extension/README.md
Original file line number Diff line number Diff line change
@@ -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)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shared_preload_libraries='pg_stat_statements'
3 changes: 3 additions & 0 deletions examples/enable-extension/postgresql-init/set_passwords.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "CREATE EXTENSION pg_stat_statements;" | psql

0 comments on commit 62a947e

Please sign in to comment.