Skip to content

๐Ÿงฉ Postgres Extensions

SuperStack supports PostgreSQL extensions, letting you add powerful features like cryptographic functions or JWT handling.

๐Ÿ› ๏ธ Building an Extension from Source

Some extensions (like pgjwt) must be compiled manually.

1. Clone the Extension Source

git clone https://github.com/michelp/pgjwt postgres/pgjwt

2. Modify the Postgres Dockerfile

Edit the Postgres Dockerfile to install build tools and compile the extension:

postgres/Dockerfile
RUN apt-get update && apt-get install -y \
    build-essential \
    postgresql-server-dev-17

# pgjwt - used by the auth schema
COPY ./pgjwt /pgjwt
WORKDIR /pgjwt
RUN make && make install

# Reset workdir
WORKDIR /var/lib/postgresql

๐Ÿงผ Set WORKDIR back to the default to avoid unintended effects.

3. Rebuild the Container

docker compose build postgres

Thatโ€™s it โ€” the extension is now available to load in your migrations.

๐Ÿ”Œ Loading an Extension

To load extensions, create a migration file such as:

postgres/migrations/01-extensions.sql
create extension pgcrypto;

โš ๏ธ create extension is non-transactional, so donโ€™t wrap this in BEGIN/COMMIT.