diff --git a/Dockerfile b/Dockerfile index 1fe08b6..8ebf47d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,12 @@ -# Lean PostgreSQL image with pgvector, PostGIS, and pg_textsearch +# Lean PostgreSQL image with pgvector, PostGIS, pg_textsearch, pg_cron, and pg_partman # Multi-stage build - all toolchains discarded, only artifacts kept ARG PG_VERSION=18 ARG PGVECTOR_VERSION=0.8.2 ARG POSTGIS_VERSION=3.6.2 -ARG PG_TEXTSEARCH_VERSION=0.6.1 +ARG PG_TEXTSEARCH_VERSION=1.2.0 +ARG PG_CRON_VERSION=1.6.7 +ARG PG_PARTMAN_VERSION=5.4.3 ############################################# # Stage 1: Build extensions @@ -14,6 +16,8 @@ FROM postgres:${PG_VERSION}-alpine AS builder ARG PGVECTOR_VERSION ARG POSTGIS_VERSION ARG PG_TEXTSEARCH_VERSION +ARG PG_CRON_VERSION +ARG PG_PARTMAN_VERSION RUN apk add --no-cache \ git \ @@ -59,6 +63,18 @@ RUN git clone --branch v${PG_TEXTSEARCH_VERSION} --depth 1 https://github.com/ti make -j$(nproc) && \ make install +# pg_cron (job scheduler) +RUN git clone --branch v${PG_CRON_VERSION} --depth 1 https://github.com/citusdata/pg_cron.git && \ + cd pg_cron && \ + make -j$(nproc) && \ + make install + +# pg_partman (partition management) +RUN git clone --branch v${PG_PARTMAN_VERSION} --depth 1 https://github.com/pgpartman/pg_partman.git && \ + cd pg_partman && \ + make -j$(nproc) && \ + make install + ############################################# # Stage 2: Final lean runtime image ############################################# @@ -78,8 +94,8 @@ RUN apk add --no-cache \ 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 +# Preload extensions that require shared_preload_libraries +RUN echo "shared_preload_libraries = 'pg_textsearch,pg_cron,pg_partman_bgw'" >> /usr/local/share/postgresql/postgresql.conf.sample LABEL org.opencontainers.image.source="https://github.com/constructive-io/docker" -LABEL org.opencontainers.image.description="PostgreSQL 18 with pgvector, PostGIS, and pg_textsearch" +LABEL org.opencontainers.image.description="PostgreSQL 18 with pgvector, PostGIS, pg_textsearch, pg_cron, and pg_partman" diff --git a/Makefile b/Makefile index 2b399f4..3b2dfce 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,8 @@ test: build CREATE EXTENSION vector; \ CREATE EXTENSION postgis; \ CREATE EXTENSION pg_textsearch; \ + CREATE EXTENSION pg_cron; \ + CREATE EXTENSION pg_partman; \ SELECT 'all extensions OK';" @docker stop $(CONTAINER_NAME)-test > /dev/null @docker rm $(CONTAINER_NAME)-test > /dev/null diff --git a/README.md b/README.md index 0a73de4..3fac3ad 100644 --- a/README.md +++ b/README.md @@ -8,24 +8,26 @@ Lean PostgreSQL 18 image with essential extensions for modern applications. ## Extensions -| Extension | Description | -|-----------|-------------| -| [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 | +| Extension | Version | Description | +|-----------|---------|-------------| +| [pgvector](https://github.com/pgvector/pgvector) | 0.8.2 | Vector similarity search for embeddings | +| [PostGIS](https://postgis.net/) | 3.6.2 | Spatial and geographic data | +| [pg_textsearch](https://github.com/timescale/pg_textsearch) | 1.2.0 | BM25 full-text search | +| [pg_cron](https://github.com/citusdata/pg_cron) | 1.6.7 | Job scheduler for periodic tasks | +| [pg_partman](https://github.com/pgpartman/pg_partman) | 5.4.3 | Partition management | ## Usage ```bash # Pull the image -docker pull ghcr.io/constructive-io/docker:latest +docker pull ghcr.io/constructive-io/docker/postgres-plus:latest # Run docker run -d \ --name postgres \ -e POSTGRES_PASSWORD=secret \ -p 5432:5432 \ - ghcr.io/constructive-io/docker:latest + ghcr.io/constructive-io/docker/postgres-plus:latest ``` Enable extensions as needed: @@ -34,6 +36,8 @@ Enable extensions as needed: CREATE EXTENSION vector; CREATE EXTENSION postgis; CREATE EXTENSION pg_textsearch; +CREATE EXTENSION pg_cron; +CREATE EXTENSION pg_partman; ``` ## Build @@ -51,7 +55,7 @@ make clean # Remove image ```bash docker buildx build \ --platform linux/amd64,linux/arm64 \ - -t docker.io/constructiveio/postgres:18 \ - -t docker.io/constructiveio/postgres:latest \ + -t ghcr.io/constructive-io/docker/postgres-plus:18 \ + -t ghcr.io/constructive-io/docker/postgres-plus:latest \ --push . ```