From dcf4169d3d4f4913d746618c824692b2dae079f0 Mon Sep 17 00:00:00 2001 From: Maxime Killinger Date: Mon, 3 Aug 2026 18:14:08 +0200 Subject: [PATCH] feat(docker): add PostGIS and remove unstable PG18 support - Install PostGIS (postgresql--postgis-3) in the final image. - Add postgis and postgis_topology to init-extensions.sh. - Add test script for PostGIS to the CI workflow. - Update README.md to reflect PostGIS integration. - Remove PG18 from CI matrix because of ABI incompatibility between TimescaleDB headers and the vchord-postgres PG18 runtime (missing palloc0_mul). PG18 support will be restored when VectorChord releases a stable PG18 image. --- .gitea/workflows/docker-build.yml | 11 +++++++---- Dockerfile | 13 +++++++++++-- README.md | 16 ++++++++-------- init-extensions.sh | 4 +++- tests/test-5-postgis.sql | 28 ++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 tests/test-5-postgis.sql diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index 3d6b8c0..a2738d4 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - pg_version: [15, 16, 17, 18] + pg_version: [15, 16, 17] steps: - name: 📥 Checkout code uses: https://github.com/actions/checkout@v4 @@ -69,6 +69,9 @@ jobs: - name: "🧪 Test 4: Hybrid Scenarios" run: docker exec test-pg${{ matrix.pg_version }} psql -U postgres -f /tmp/tests/test-4-hybrid.sql + - name: "🧪 Test 5: PostGIS" + run: docker exec test-pg${{ matrix.pg_version }} psql -U postgres -f /tmp/tests/test-5-postgis.sql + - name: 🧹 Cleanup test container if: always() run: docker rm -f test-pg${{ matrix.pg_version }} || true @@ -83,14 +86,14 @@ jobs: tags: | gitea.killinger.fr/maxime.killinger/postgres-ts-vectors:pg${{ matrix.pg_version }} - - name: 🏷️ Tag latest (PG18 only) - if: matrix.pg_version == 18 + - name: 🏷️ Tag latest (PG17 only) + if: matrix.pg_version == 17 uses: https://github.com/docker/build-push-action@v5 with: context: . push: true build-args: | - PG_VERSION=18 + PG_VERSION=17 tags: | gitea.killinger.fr/maxime.killinger/postgres-ts-vectors:latest diff --git a/Dockerfile b/Dockerfile index 8ee10a8..6f22635 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,8 +31,8 @@ RUN git clone --branch ${TIMESCALEDB_VERSION} --depth 1 https://github.com/times FROM tensorchord/vchord-postgres:pg${PG_VERSION}-v1.1.1 AS final # OCI Labels -LABEL org.opencontainers.image.title="TimescaleDB + VectorChord + pgvector" -LABEL org.opencontainers.image.description="PostgreSQL with TimescaleDB, VectorChord, and pgvector extensions pre-installed" +LABEL org.opencontainers.image.title="TimescaleDB + VectorChord + pgvector + PostGIS" +LABEL org.opencontainers.image.description="PostgreSQL with TimescaleDB, VectorChord, pgvector, and PostGIS extensions pre-installed" LABEL org.opencontainers.image.source="https://gitea.killinger.fr/maxime.killinger/postgres-ts-vectors" LABEL org.opencontainers.image.vendor="Maxime Killinger" LABEL org.opencontainers.image.licenses="Apache-2.0" @@ -42,6 +42,15 @@ LABEL org.opencontainers.image.base.name="tensorchord/vchord-postgres:pg${PG_VER COPY --from=builder /tmp/timescaledb/usr/lib/postgresql/ /usr/lib/postgresql/ COPY --from=builder /tmp/timescaledb/usr/share/postgresql/ /usr/share/postgresql/ +USER root + +# Install PostGIS +RUN apt-get update && apt-get install -y --no-install-recommends \ + postgresql-$PG_MAJOR-postgis-3 \ + postgresql-$PG_MAJOR-postgis-3-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + # Add init script for auto-extension creation COPY init-extensions.sh /docker-entrypoint-initdb.d/ RUN sed -i 's/\r$//' /docker-entrypoint-initdb.d/init-extensions.sh && \ diff --git a/README.md b/README.md index 2957ee7..966ea3a 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,21 @@ -# TimescaleDB + VectorChord + pgvector +# TimescaleDB + VectorChord + pgvector + PostGIS [![Build Status](https://gitea.killinger.fr/maxime.killinger/postgres-ts-vectors/actions/workflows/docker-build.yml/badge.svg)](https://gitea.killinger.fr/maxime.killinger/postgres-ts-vectors/actions) -Docker image combining **PostgreSQL** with three powerful extensions: +Docker image combining **PostgreSQL** with four powerful extensions: - **[TimescaleDB](https://www.timescale.com/)** - Time-series database extension - **[VectorChord](https://vectorchord.ai/)** - High-performance vector similarity search - **[pgvector](https://github.com/pgvector/pgvector)** - Open-source vector similarity search +- **[PostGIS](https://postgis.net/)** - Geographic objects support ## Supported PostgreSQL Versions -| Tag | PostgreSQL | TimescaleDB | VectorChord | pgvector | -|-----|------------|-------------|-------------|----------| -| `pg15` | 15 | 2.28.3 | 1.1.1 | 0.8.1 | -| `pg16` | 16 | 2.28.3 | 1.1.1 | 0.8.1 | -| `pg17` | 17 | 2.28.3 | 1.1.1 | 0.8.1 | -| `pg18`, `latest` | 18 | 2.28.3 | 1.1.1 | 0.8.1 | +| Tag | PostgreSQL | TimescaleDB | VectorChord | pgvector | PostGIS | +|-----|------------|-------------|-------------|----------|---------| +| `pg15` | 15 | 2.28.3 | 1.1.1 | 0.8.1 | 3.x | +| `pg16` | 16 | 2.28.3 | 1.1.1 | 0.8.1 | 3.x | +| `pg17`, `latest` | 17 | 2.28.3 | 1.1.1 | 0.8.1 | 3.x | ## Quick Start diff --git a/init-extensions.sh b/init-extensions.sh index b2f92e9..a832485 100644 --- a/init-extensions.sh +++ b/init-extensions.sh @@ -5,6 +5,8 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-E CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE; CREATE EXTENSION IF NOT EXISTS vector; CREATE EXTENSION IF NOT EXISTS vchord CASCADE; + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; EOSQL -echo "Extensions timescaledb, vector, and vchord have been created." +echo "Extensions timescaledb, vector, vchord, and postgis have been created." diff --git a/tests/test-5-postgis.sql b/tests/test-5-postgis.sql new file mode 100644 index 0000000..48dc353 --- /dev/null +++ b/tests/test-5-postgis.sql @@ -0,0 +1,28 @@ +-- Test 5: PostGIS +\set ON_ERROR_STOP on + +CREATE TABLE spatial_data ( + id serial PRIMARY KEY, + geom geometry(Point, 4326) +); + +INSERT INTO spatial_data (geom) VALUES (ST_GeomFromText('POINT(-71.060316 48.432044)', 4326)); +INSERT INTO spatial_data (geom) VALUES (ST_GeomFromText('POINT(-71.059773 48.432867)', 4326)); + +DO $$ +DECLARE + dist float; +BEGIN + SELECT ST_Distance( + (SELECT geom FROM spatial_data WHERE id = 1), + (SELECT geom FROM spatial_data WHERE id = 2) + ) INTO dist; + + IF dist IS NULL THEN + RAISE EXCEPTION 'PostGIS distance calculation failed'; + END IF; + RAISE NOTICE 'PostGIS Check: OK, distance is %', dist; +END +$$; + +DROP TABLE spatial_data;