Skip to content

Commit ab497cf

Browse files
WarpSQL: Add PostGIS extension smoke tests
1. Add smoke tests to the GitHub Actions workflow to verify the functionality of the PostGIS extension. 2. This includes creating the PostGIS extension, checking its version, and testing basic geometry functions.
1 parent 151b195 commit ab497cf

6 files changed

Lines changed: 129 additions & 43 deletions

File tree

.github/workflows/smoke-test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ jobs:
6262
psql -c "INSERT INTO test_distributed_table (data) VALUES ('test data');"
6363
psql -c "SELECT * FROM test_distributed_table;"
6464
65+
echo "Test PostGIS Extension"
66+
psql -c "CREATE EXTENSION postgis;" || true
67+
psql -c "SELECT PostGIS_Version();"
68+
69+
echo "Test PostGIS Geometry Function"
70+
psql -c "CREATE TABLE test_geometry_table (id serial primary key, geom geometry(Point, 4326));"
71+
psql -c "INSERT INTO test_geometry_table (geom) VALUES (ST_GeomFromText('POINT(0 0)', 4326));"
72+
psql -c "SELECT * FROM test_geometry_table;"
73+
6574
break
6675
fi
6776
sleep 1

Dockerfile

Lines changed: 90 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ RUN set -ex \
7373
&& rm -rf /build \
7474
&& sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" /usr/local/share/postgresql/postgresql.conf.sample
7575

76-
# Add Citus to shared_preload_libraries
76+
# Update to shared_preload_libraries
7777
RUN echo "shared_preload_libraries = 'citus,timescaledb,pg_stat_statements'" >> /usr/local/share/postgresql/postgresql.conf.sample
7878

7979
# Adding PG Vector
@@ -132,43 +132,99 @@ RUN set -ex \
132132
&& rm -rf /tmp/citus.tar.gz /tmp/citus-${CITUS_VERSION} \
133133
&& apk del .citus-deps .citus-build-deps
134134

135-
## Adding PostGIS
136-
# Install PostGIS dependencies
137-
RUN apk add --no-cache --virtual .postgis-deps \
138-
geos-dev \
139-
gdal-dev \
140-
proj-dev \
141-
curl \
142-
json-c-dev \
143-
protobuf-c-dev
144135

145-
# Install PostGIS
146136
ARG POSTGIS_VERSION
147-
RUN set -ex \
148-
&& apk add --no-cache --virtual .postgis-build-deps \
149-
gcc \
137+
ARG POSTGIS_SHA256
138+
139+
RUN set -eux \
140+
\
141+
&& if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \
142+
set -eux ; \
143+
export GEOS_ALPINE_VER=3.11 ; \
144+
export GDAL_ALPINE_VER=3.5 ; \
145+
export PROJ_ALPINE_VER=9.1 ; \
146+
elif [ $(printf %.1s "$POSTGIS_VERSION") == 2 ]; then \
147+
set -eux ; \
148+
export GEOS_ALPINE_VER=3.8 ; \
149+
export GDAL_ALPINE_VER=3.2 ; \
150+
export PROJ_ALPINE_VER=7.2 ; \
151+
\
152+
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.14/main' >> /etc/apk/repositories ; \
153+
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.14/community' >> /etc/apk/repositories ; \
154+
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.13/main' >> /etc/apk/repositories ; \
155+
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.13/community' >> /etc/apk/repositories ; \
156+
\
157+
else \
158+
set -eux ; \
159+
echo ".... unknown \$POSTGIS_VERSION ...." ; \
160+
exit 1 ; \
161+
fi \
162+
\
163+
&& apk add --no-cache --virtual .fetch-deps \
164+
ca-certificates \
165+
openssl \
166+
tar \
167+
\
168+
&& wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \
169+
&& echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \
170+
&& mkdir -p /usr/src/postgis \
171+
&& tar \
172+
--extract \
173+
--file postgis.tar.gz \
174+
--directory /usr/src/postgis \
175+
--strip-components 1 \
176+
&& rm postgis.tar.gz \
177+
\
178+
&& apk add --no-cache --virtual .build-deps \
179+
\
180+
gdal-dev~=${GDAL_ALPINE_VER} \
181+
geos-dev~=${GEOS_ALPINE_VER} \
182+
proj-dev~=${PROJ_ALPINE_VER} \
183+
\
184+
autoconf \
185+
automake \
186+
clang-dev \
187+
cunit-dev \
188+
file \
150189
g++ \
151-
libc-dev \
152-
make \
190+
gcc \
191+
gettext-dev \
192+
git \
193+
json-c-dev \
194+
libtool \
153195
libxml2-dev \
154-
musl-dev \
196+
llvm-dev \
197+
make \
198+
pcre-dev \
155199
perl \
156-
clang \
157-
geos-dev \
158-
gdal-dev \
159-
proj-dev \
160200
protobuf-c-dev \
161-
llvm15-dev \
162-
json-c-dev \
163-
&& POSTGIS_DOWNLOAD_URL="https://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz" \
164-
&& curl -L -o /tmp/postgis.tar.gz "${POSTGIS_DOWNLOAD_URL}" \
165-
&& tar -C /tmp -xvf /tmp/postgis.tar.gz \
166-
&& chown -R postgres:postgres /tmp/postgis-${POSTGIS_VERSION} \
167-
&& cd /tmp/postgis-${POSTGIS_VERSION} \
168-
&& PATH="/usr/local/pgsql/bin:$PATH" ./configure \
169-
&& make \
201+
\
202+
# build PostGIS
203+
\
204+
&& cd /usr/src/postgis \
205+
&& gettextize \
206+
&& ./autogen.sh \
207+
&& ./configure \
208+
--with-pcredir="$(pcre-config --prefix)" \
209+
&& make -j$(nproc) \
170210
&& make install \
171-
&& cd ~ \
172-
&& rm -rf /tmp/postgis.tar.gz /tmp/postgis-${POSTGIS_VERSION} \
173-
&& apk del .postgis-deps .postgis-build-deps
174-
211+
\
212+
# add .postgis-rundeps
213+
&& apk add --no-cache --virtual .postgis-rundeps \
214+
\
215+
gdal~=${GDAL_ALPINE_VER} \
216+
geos~=${GEOS_ALPINE_VER} \
217+
proj~=${PROJ_ALPINE_VER} \
218+
\
219+
json-c \
220+
libstdc++ \
221+
pcre \
222+
protobuf-c \
223+
\
224+
# ca-certificates: for accessing remote raster files
225+
# fix https://github.com/postgis/docker-postgis/issues/307
226+
ca-certificates \
227+
# clean
228+
&& cd / \
229+
&& rm -rf /usr/src/postgis \
230+
&& apk del .fetch-deps .build-deps

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ NAME=postgres
44
ORG=samagragovernance
55
PG_VER=pg15
66
CITUS_VERSION="11.2.0"
7-
POSTGIS_VERSION=3.1.4
7+
POSTGIS_VERSION=3.3.2
8+
POSTGIS_SHA256=2a6858d1df06de1c5f85a5b780773e92f6ba3a5dc09ac31120ac895242f5a77b
89
PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-)
910
TS_VERSION=main
1011
PREV_TS_VERSION=$(shell wget --quiet -O - https://raw.githubusercontent.com/timescale/timescaledb/${TS_VERSION}/version.config | grep update_from_version | sed -e 's!update_from_version = !!')
@@ -56,7 +57,7 @@ default: image
5657
touch .build_$(TS_VERSION)_$(PG_VER)_oss
5758

5859
.build_$(TS_VERSION)_$(PG_VER): Dockerfile
59-
docker build --build-arg PG_VERSION=$(PG_VER_NUMBER) --build-arg TS_VERSION=$(TS_VERSION) --build-arg PREV_IMAGE=$(PREV_IMAGE) --build-arg CITUS_VERSION=$(CITUS_VERSION) --build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) $(TAG) .
60+
docker build --build-arg PG_VERSION=$(PG_VER_NUMBER) --build-arg TS_VERSION=$(TS_VERSION) --build-arg PREV_IMAGE=$(PREV_IMAGE) --build-arg CITUS_VERSION=$(CITUS_VERSION) --build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) --build-arg POSTGIS_SHA256=$(POSTGIS_SHA256) $(TAG) .
6061
touch .build_$(TS_VERSION)_$(PG_VER)
6162

6263
image: .build_$(TS_VERSION)_$(PG_VER)

bitnami/Dockerfile

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ RUN set -ex \
8080
make \
8181
cmake \
8282
wget \
83-
postgis \
8483
&& mkdir -p /build/ \
8584
&& git clone https://github.com/timescale/timescaledb /build/timescaledb \
8685
\
@@ -126,7 +125,25 @@ RUN set -ex \
126125
/var/tmp/* \
127126
\
128127
# Update shared_preload_libraries
129-
&& sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'citus,timescaledb,postgis'/g" /opt/bitnami/postgresql/conf/postgresql.conf
128+
&& sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'citus,timescaledb'/g" /opt/bitnami/postgresql/conf/postgresql.conf
129+
130+
# Add PostGIS Extension
131+
ARG POSTGIS_MAJOR
132+
ARG PG_MAJOR
133+
ARG POSTGIS_VERSION
134+
135+
RUN apt-get update \
136+
&& apt-get install -y lsb-release gnupg2 \
137+
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list \
138+
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
139+
&& apt-get update \
140+
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
141+
&& apt-get install -y --no-install-recommends \
142+
ca-certificates \
143+
\
144+
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \
145+
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
146+
&& rm -rf /var/lib/apt/lists/*
130147

131148
USER 1001
132149

bitnami/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ NAME=timescaledb
44
ORG=timescaledev
55
PG_VER=pg15
66
CITUS_VERSION="11.2.0"
7-
POSTGIS_VERSION=3.1.4
7+
POSTGIS_MAJOR=3
8+
PG_MAJOR=15
9+
POSTGIS_VERSION=3.3.2+dfsg-1.pgdg110+1
10+
811
PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-)
912

1013
TS_VERSION=main
@@ -23,7 +26,7 @@ default: image
2326
.build_$(TS_VERSION)_$(PG_VER): Dockerfile
2427
test -n "$(TS_VERSION)" # TS_VERSION
2528
test -n "$(PREV_TS_VERSION)" # PREV_TS_VERSION
26-
docker build -f ./Dockerfile --build-arg PG_VERSION=$(PG_VER_NUMBER) --build-arg TS_VERSION=$(TS_VERSION) --build-arg PREV_IMAGE=$(PREV_IMAGE) --build-arg CITUS_VERSION=$(CITUS_VERSION) --build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) $(TAG) ..
29+
docker build -f ./Dockerfile --build-arg PG_VERSION=$(PG_VER_NUMBER) --build-arg TS_VERSION=$(TS_VERSION) --build-arg PREV_IMAGE=$(PREV_IMAGE) --build-arg CITUS_VERSION=$(CITUS_VERSION) --build-arg POSTGIS_MAJOR=$(POSTGIS_MAJOR) --build-arg PG_MAJOR=$(PG_MAJOR) --build-arg POSTGIS_VERSION=$(POSTGIS_VERSION) $(TAG) ..
2730
touch .build_$(TS_VERSION)_$(PG_VER)-bitnami
2831

2932
image: .build_$(TS_VERSION)_$(PG_VER)

bitnami/timescaledb-bitnami-entrypoint.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/env bash
22

3-
# We have to use the Bitnami configuration variable to add TimescaleDB, Citus, and PostGIS to
3+
# We have to use the Bitnami configuration variable to add TimescaleDB, Citus to
44
# the shared preload list, or else it gets overwritten.
55
if [ -z "$POSTGRESQL_SHARED_PRELOAD_LIBRARIES" ]
66
then
7-
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="citus,timescaledb,postgis"
7+
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="citus,timescaledb"
88
else
9-
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="citus,timescaledb,postgis,$POSTGRESQL_SHARED_PRELOAD_LIBRARIES"
9+
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="citus,timescaledb,$POSTGRESQL_SHARED_PRELOAD_LIBRARIES"
1010
fi
1111
export POSTGRESQL_SHARED_PRELOAD_LIBRARIES
1212

0 commit comments

Comments
 (0)