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
44 changes: 44 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: constructive-io/docker/postgres-plus
DOCKERHUB_IMAGE: constructiveio/postgres-plus
PG_VERSION: '18'

concurrency:
Expand Down Expand Up @@ -110,6 +111,9 @@ jobs:
runs-on: ubuntu-latest
needs: build-postgres-plus

env:
DOCKERHUB_ENABLED: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }}

permissions:
contents: read
packages: write
Expand Down Expand Up @@ -175,3 +179,43 @@ jobs:
echo "Creating multi-arch manifest for $tag"
docker buildx imagetools create -t "$tag" $digests
done

- name: Log in to Docker Hub
if: env.DOCKERHUB_ENABLED == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract Docker Hub metadata
if: env.DOCKERHUB_ENABLED == 'true'
id: meta-dockerhub
uses: docker/metadata-action@v5
with:
images: docker.io/${{ env.DOCKERHUB_IMAGE }}
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=${{ env.PG_VERSION }},enable=${{ github.ref == 'refs/heads/main' }}
type=sha,format=short,prefix=
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}

- name: Create and push Docker Hub manifests
if: env.DOCKERHUB_ENABLED == 'true'
run: |
set -euo pipefail

image="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
digest_dir="${{ runner.temp }}/digests"

digests=""
for digest_file in "$digest_dir"/*; do
digest="$(basename "$digest_file")"
digests="$digests $image@sha256:$digest"
done

echo "${{ steps.meta-dockerhub.outputs.tags }}" | while read -r tag; do
[ -z "$tag" ] && continue
echo "Creating multi-arch manifest for $tag"
docker buildx imagetools create -t "$tag" $digests
done
24 changes: 8 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Lean PostgreSQL image with pgvector, PostGIS, pg_textsearch, pg_cron, and pg_partman
# Lean PostgreSQL image with pgvector, PostGIS, pg_textsearch, 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=1.2.0
ARG PG_CRON_VERSION=1.6.7
ARG PG_TEXTSEARCH_VERSION=1.3.1
ARG PG_PARTMAN_VERSION=5.4.3

#############################################
Expand All @@ -16,15 +15,12 @@ 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 \
build-base \
postgresql-dev \
clang19 \
llvm19 \
curl \
# PostGIS dependencies
geos-dev \
Expand All @@ -41,8 +37,10 @@ RUN apk add --no-cache \

WORKDIR /build

# Symlink for LLVM JIT (postgres expects llvm-lto-19)
RUN ln -s /usr/bin/llvm19-lto /usr/bin/llvm-lto-19
# Install the clang/llvm major version postgres was compiled with (for JIT bitcode)
RUN ver="$(sed -n 's/^CLANG *= *clang-//p' /usr/local/lib/postgresql/pgxs/src/Makefile.global)" && \
apk add --no-cache "clang${ver}" "llvm${ver}" && \
ln -sf "/usr/bin/llvm${ver}-lto" "/usr/bin/llvm-lto-${ver}"

# pgvector
RUN git clone --branch v${PGVECTOR_VERSION} --depth 1 https://github.com/pgvector/pgvector.git && \
Expand All @@ -63,12 +61,6 @@ 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 && \
Expand All @@ -95,8 +87,8 @@ COPY --from=builder /usr/local/lib/postgresql/ /usr/local/lib/postgresql/
COPY --from=builder /usr/local/share/postgresql/ /usr/local/share/postgresql/

# Preload extensions that require shared_preload_libraries
RUN echo "shared_preload_libraries = 'pg_stat_statements,pg_textsearch,pg_cron,pg_partman_bgw'" >> /usr/local/share/postgresql/postgresql.conf.sample && \
RUN echo "shared_preload_libraries = 'pg_stat_statements,pg_textsearch,pg_partman_bgw'" >> /usr/local/share/postgresql/postgresql.conf.sample && \
echo "track_io_timing = on" >> /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, pg_textsearch, pg_cron, pg_partman, and pg_stat_statements"
LABEL org.opencontainers.image.description="PostgreSQL 18 with pgvector, PostGIS, pg_textsearch, pg_partman, and pg_stat_statements"
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ 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
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Lean PostgreSQL 18 image with essential extensions for modern applications.
|-----------|---------|-------------|
| [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_textsearch](https://github.com/timescale/pg_textsearch) | 1.3.1 | BM25 full-text search |
| [pg_partman](https://github.com/pgpartman/pg_partman) | 5.4.3 | Partition management |
| [pg_stat_statements](https://www.postgresql.org/docs/current/pgstatstatements.html) | built-in | Query performance statistics |

Expand All @@ -39,7 +38,6 @@ Enable extensions as needed:
CREATE EXTENSION vector;
CREATE EXTENSION postgis;
CREATE EXTENSION pg_textsearch;
CREATE EXTENSION pg_cron;
CREATE EXTENSION pg_partman;
CREATE EXTENSION pg_stat_statements;
```
Expand Down
Loading