Skip to content
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
19 changes: 6 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Lean PostgreSQL image with pgvector, PostGIS, pg_textsearch, and pgsodium
# Lean PostgreSQL image with pgvector, PostGIS, and pg_textsearch
# Multi-stage build - all toolchains discarded, only artifacts kept

ARG PG_VERSION=17
ARG PGVECTOR_VERSION=0.8.0
ARG POSTGIS_VERSION=3.5.1
ARG PG_TEXTSEARCH_VERSION=0.6.0
ARG PGSODIUM_VERSION=3.1.9

#############################################
# Stage 1: Build extensions
Expand All @@ -15,7 +14,6 @@ FROM postgres:${PG_VERSION}-alpine AS builder
ARG PGVECTOR_VERSION
ARG POSTGIS_VERSION
ARG PG_TEXTSEARCH_VERSION
ARG PGSODIUM_VERSION

RUN apk add --no-cache \
git \
Expand All @@ -32,7 +30,6 @@ RUN apk add --no-cache \
protobuf-c-dev \
libxml2-dev \
pcre2-dev \
libsodium-dev \
# PostGIS build tools
perl \
flex \
Expand Down Expand Up @@ -62,12 +59,6 @@ RUN git clone --branch v${PG_TEXTSEARCH_VERSION} --depth 1 https://github.com/ti
make -j$(nproc) && \
make install

# pgsodium
RUN git clone --branch v${PGSODIUM_VERSION} --depth 1 https://github.com/michelp/pgsodium.git && \
cd pgsodium && \
make -j$(nproc) && \
make install

#############################################
# Stage 2: Final lean runtime image
#############################################
Expand All @@ -81,12 +72,14 @@ RUN apk add --no-cache \
json-c \
protobuf-c \
libxml2 \
pcre2 \
libsodium
pcre2

# Copy compiled extensions from builder
COPY --from=builder /usr/local/lib/postgresql/ /usr/local/lib/postgresql/
COPY --from=builder /usr/local/share/postgresql/ /usr/local/share/postgresql/

# Preload pg_textsearch so CREATE EXTENSION works without manual config
RUN echo "shared_preload_libraries = 'pg_textsearch'" >> /usr/local/share/postgresql/postgresql.conf.sample

LABEL org.opencontainers.image.source="https://github.com/constructive-io/docker"
LABEL org.opencontainers.image.description="PostgreSQL 17 with pgvector, PostGIS, pg_textsearch, and pgsodium"
LABEL org.opencontainers.image.description="PostgreSQL 17 with pgvector, PostGIS, and pg_textsearch"
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Lean PostgreSQL 17 image with essential extensions for modern applications.
| [pgvector](https://github.com/pgvector/pgvector) | Vector similarity search for embeddings |
| [PostGIS](https://postgis.net/) | Spatial and geographic data |
| [pg_textsearch](https://www.tigerdata.com/docs/use-timescale/latest/extensions/pg-textsearch) | BM25 full-text search |
| [pgsodium](https://github.com/michelp/pgsodium) | Encryption using libsodium |

## Usage

Expand All @@ -35,7 +34,6 @@ Enable extensions as needed:
CREATE EXTENSION vector;
CREATE EXTENSION postgis;
CREATE EXTENSION pg_textsearch;
CREATE EXTENSION pgsodium;
```

## Build
Expand Down