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

Add example how to enable extension #394

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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