From fb5d1ad36669d5f6fbced6715da958009d7b17ca Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Sun, 29 Nov 2026 16:25:29 -0500 Subject: [PATCH] feat: enable pkg-slim in postgres runtime images Enable the default pkg-slim tiers before installing PostgreSQL packages in the production stage so headers, static archives, docs, and unused compiler binaries are skipped at extraction time while keeping pgvector and LLVM JIT functional. Document how downstream extension builders disable pkg-slim and restore PostgreSQL headers when building from this image. --- Containerfile.pkg | 3 ++- Containerfile.pkg.j2 | 3 ++- compose.yaml | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Containerfile.pkg b/Containerfile.pkg index 2843390..7e5a994 100644 --- a/Containerfile.pkg +++ b/Containerfile.pkg @@ -59,7 +59,8 @@ LABEL org.opencontainers.image.title="PostgreSQL ${PG_VERSION}" \ # Install PostgreSQL (and prebuilt pgvector when available) COPY --from=builder /out /tmp/pgvector-out -RUN pkg update && \ +RUN pkg-slim enable && \ + pkg update && \ pkg install -y ${PACKAGES} && \ if ls /tmp/pgvector-out/postgresql${PG_VERSION}-pgvector-* >/dev/null 2>&1; then \ pkg add /tmp/pgvector-out/postgresql${PG_VERSION}-pgvector-*; \ diff --git a/Containerfile.pkg.j2 b/Containerfile.pkg.j2 index a12ff6b..e975d10 100644 --- a/Containerfile.pkg.j2 +++ b/Containerfile.pkg.j2 @@ -60,7 +60,8 @@ LABEL org.opencontainers.image.title="{{ title }} ${PG_VERSION}" \ # Install PostgreSQL (and prebuilt pgvector when available) COPY --from=builder /out /tmp/pgvector-out -RUN pkg update && \ +RUN pkg-slim enable && \ + pkg update && \ pkg install -y ${PACKAGES} && \ if ls /tmp/pgvector-out/postgresql${PG_VERSION}-pgvector-* >/dev/null 2>&1; then \ pkg add /tmp/pgvector-out/postgresql${PG_VERSION}-pgvector-*; \ diff --git a/compose.yaml b/compose.yaml index 6fd9ac5..159dc9d 100644 --- a/compose.yaml +++ b/compose.yaml @@ -32,6 +32,20 @@ x-daemonless: `*.sql.gz`. They run as `bsd`, not as root, and connect as `POSTGRES_USER`, the superuser that owns the databases. + ## Building extensions + + This image enables `pkg-slim` (`docs`, `dev`, and `toolchain` tiers), which + strips headers, static archives, and compiler binaries while keeping + PostgreSQL, `pgvector`, and LLVM JIT working at runtime. Downstream builder + stages compiling extensions against this image should disable slimming and + reinstall the PostgreSQL headers first: + + ```dockerfile + RUN pkg-slim disable && \ + pkg update && \ + pkg install -fy postgresql${PG_VERSION}-client postgresql${PG_VERSION}-server gettext-runtime icu llvm19 + ``` + services: postgres: image: ghcr.io/daemonless/postgres:latest