1- # Lean PostgreSQL image with pgvector, PostGIS, pg_textsearch, and pgsodium
1+ # Lean PostgreSQL image with pgvector, PostGIS, and pg_textsearch
22# Multi-stage build - all toolchains discarded, only artifacts kept
33
44ARG PG_VERSION=17
55ARG PGVECTOR_VERSION=0.8.0
66ARG POSTGIS_VERSION=3.5.1
77ARG PG_TEXTSEARCH_VERSION=0.6.0
8- ARG PGSODIUM_VERSION=3.1.9
98
109# ############################################
1110# Stage 1: Build extensions
@@ -15,7 +14,6 @@ FROM postgres:${PG_VERSION}-alpine AS builder
1514ARG PGVECTOR_VERSION
1615ARG POSTGIS_VERSION
1716ARG PG_TEXTSEARCH_VERSION
18- ARG PGSODIUM_VERSION
1917
2018RUN apk add --no-cache \
2119 git \
@@ -32,7 +30,6 @@ RUN apk add --no-cache \
3230 protobuf-c-dev \
3331 libxml2-dev \
3432 pcre2-dev \
35- libsodium-dev \
3633 # PostGIS build tools
3734 perl \
3835 flex \
@@ -62,12 +59,6 @@ RUN git clone --branch v${PG_TEXTSEARCH_VERSION} --depth 1 https://github.com/ti
6259 make -j$(nproc) && \
6360 make install
6461
65- # pgsodium
66- RUN git clone --branch v${PGSODIUM_VERSION} --depth 1 https://github.com/michelp/pgsodium.git && \
67- cd pgsodium && \
68- make -j$(nproc) && \
69- make install
70-
7162# ############################################
7263# Stage 2: Final lean runtime image
7364# ############################################
@@ -81,12 +72,14 @@ RUN apk add --no-cache \
8172 json-c \
8273 protobuf-c \
8374 libxml2 \
84- pcre2 \
85- libsodium
75+ pcre2
8676
8777# Copy compiled extensions from builder
8878COPY --from=builder /usr/local/lib/postgresql/ /usr/local/lib/postgresql/
8979COPY --from=builder /usr/local/share/postgresql/ /usr/local/share/postgresql/
9080
81+ # Preload pg_textsearch so CREATE EXTENSION works without manual config
82+ RUN echo "shared_preload_libraries = 'pg_textsearch'" >> /usr/local/share/postgresql/postgresql.conf.sample
83+
9184LABEL org.opencontainers.image.source="https://github.com/constructive-io/docker"
92- LABEL org.opencontainers.image.description="PostgreSQL 17 with pgvector, PostGIS, pg_textsearch, and pgsodium "
85+ LABEL org.opencontainers.image.description="PostgreSQL 17 with pgvector, PostGIS, and pg_textsearch "
0 commit comments