Skip to content

Instantly share code, notes, and snippets.

@ToroNZ
Created March 10, 2025 04:06
Show Gist options
  • Save ToroNZ/cb06961b10134584b219c0905195f451 to your computer and use it in GitHub Desktop.
Save ToroNZ/cb06961b10134584b219c0905195f451 to your computer and use it in GitHub Desktop.
Postgres 17 with pgjwt extension

Thank you stranger: https://github.com/dminkovsky/postgres-pgjwt

Ends up with a size of 441MB (base of 438MB).

Log:

$ sudo docker run --rm -it -e POSTGRES_PASSWORD=notused toronz/postgres-pgjwt:latest

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default "max_connections" ... 100
selecting default "shared_buffers" ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2025-03-10 04:03:41.063 UTC [48] LOG:  starting PostgreSQL 17.4 (Debian 17.4-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2025-03-10 04:03:41.064 UTC [48] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-03-10 04:03:41.069 UTC [51] LOG:  database system was shut down at 2025-03-10 04:03:40 UTC
2025-03-10 04:03:41.074 UTC [48] LOG:  database system is ready to accept connections
 done
server started

/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql
psql:/docker-entrypoint-initdb.d/init.sql:3: NOTICE:  installing required extension "pgcrypto"
CREATE EXTENSION


2025-03-10 04:03:41.246 UTC [48] LOG:  received fast shutdown request
waiting for server to shut down....2025-03-10 04:03:41.247 UTC [48] LOG:  aborting any active transactions
2025-03-10 04:03:41.250 UTC [48] LOG:  background worker "logical replication launcher" (PID 54) exited with exit code 1
2025-03-10 04:03:41.251 UTC [49] LOG:  shutting down
2025-03-10 04:03:41.252 UTC [49] LOG:  checkpoint starting: shutdown immediate
2025-03-10 04:03:41.270 UTC [49] LOG:  checkpoint complete: wrote 64 buffers (0.4%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.005 s, sync=0.009 s, total=0.020 s; sync files=19, longest=0.001 s, average=0.001 s; distance=354 kB, estimate=354 kB; lsn=0/153DA58, redo lsn=0/153DA58
2025-03-10 04:03:41.278 UTC [48] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2025-03-10 04:03:41.369 UTC [1] LOG:  starting PostgreSQL 17.4 (Debian 17.4-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2025-03-10 04:03:41.369 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2025-03-10 04:03:41.369 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2025-03-10 04:03:41.371 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-03-10 04:03:41.376 UTC [64] LOG:  database system was shut down at 2025-03-10 04:03:41 UTC
2025-03-10 04:03:41.383 UTC [1] LOG:  database system is ready to accept connections
FROM postgres:17
# Install build dependencies, build pgjwt, and clean up
RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
build-essential \
git \
postgresql-server-dev-17 \
ca-certificates \
&& git clone --depth 1 https://github.com/michelp/pgjwt.git /tmp/pgjwt \
&& make -C /tmp/pgjwt install \
&& rm -rf /tmp/pgjwt \
&& apt-get remove --purge -y build-essential git postgresql-server-dev-17 ca-certificates \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY ./init.sql /docker-entrypoint-initdb.d
-- 'CASCADE' ensures any dependencies like pgcrypto are
-- also installed.
CREATE EXTENSION IF NOT EXISTS pgjwt CASCADE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment