Skip to content

Commit 2bcc905

Browse files
authored
Merge pull request #124 from PiyushRaj927/move_PostGIS
add postgis extension with smoke test
2 parents 7344e6a + 4d7b5ca commit 2bcc905

File tree

5 files changed

+139
-3
lines changed

5 files changed

+139
-3
lines changed

.github/workflows/smoke-test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ jobs:
5555
echo "Test pg_cron Extension"
5656
psql -c "CREATE EXTENSION pg_cron";
5757
psql -c "SELECT cron.schedule('30 3 * * 6',\$\$DELETE FROM events WHERE event_time < now() - interval '1 week'\$\$)";
58+
59+
echo "Test PostGIS Extension"
60+
psql -c "CREATE EXTENSION postgis;" || true
61+
psql -c "SELECT PostGIS_Version();"
62+
63+
echo "Test PostGIS Geometry Function"
64+
psql -c "CREATE TABLE test_geometry_table (id serial primary key, geom geometry(Point, 4326));"
65+
psql -c "INSERT INTO test_geometry_table (geom) VALUES (ST_GeomFromText('POINT(0 0)', 4326));"
66+
psql -c "SELECT * FROM test_geometry_table;"
67+
5868
break
5969
fi
6070
sleep 1

Dockerfile

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,73 @@ RUN set -ex \
131131
&& cd / \
132132
&& rm /tmp/pg_cron.tar.gz \
133133
&& rm -rf /tmp/pg_cron \
134-
&& apk del .pg_cron-deps .pg_cron-build-deps
134+
&& apk del .pg_cron-deps .pg_cron-build-deps
135+
136+
# Add PostGIS Extension
137+
ARG POSTGIS_VERSION
138+
139+
RUN set -eux \
140+
&& apk add --no-cache --virtual .fetch-deps \
141+
ca-certificates \
142+
openssl \
143+
tar \
144+
\
145+
&& wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \
146+
&& mkdir -p /usr/src/postgis \
147+
&& tar \
148+
--extract \
149+
--file postgis.tar.gz \
150+
--directory /usr/src/postgis \
151+
--strip-components 1 \
152+
&& rm postgis.tar.gz \
153+
\
154+
&& apk add --no-cache --virtual .build-deps \
155+
\
156+
gdal-dev \
157+
geos-dev \
158+
proj-dev \
159+
autoconf \
160+
automake \
161+
clang15 \
162+
cunit-dev \
163+
file \
164+
g++ \
165+
gcc \
166+
gettext-dev \
167+
git \
168+
json-c-dev \
169+
libtool \
170+
libxml2-dev \
171+
llvm15-dev \
172+
make \
173+
pcre-dev \
174+
perl \
175+
protobuf-c-dev \
176+
\
177+
# build PostGIS
178+
\
179+
&& cd /usr/src/postgis \
180+
&& gettextize \
181+
&& ./autogen.sh \
182+
&& ./configure \
183+
--with-pcredir="$(pcre-config --prefix)" \
184+
&& make -j$(nproc) \
185+
&& make install \
186+
\
187+
# add .postgis-rundeps
188+
&& apk add --no-cache --virtual .postgis-rundeps \
189+
\
190+
gdal \
191+
geos \
192+
proj \
193+
\
194+
json-c \
195+
libstdc++ \
196+
pcre \
197+
protobuf-c \
198+
\
199+
ca-certificates \
200+
# clean
201+
&& cd / \
202+
&& rm -rf /usr/src/postgis \
203+
&& apk del .fetch-deps .build-deps

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ PG_VER=pg15
66
PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-)
77
TS_VERSION=2.13.0
88
PG_CRON_VERSION=v1.6.0
9+
POSTGIS_VERSION=3.4.1
910
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 = !!')
1011
PREV_TS_IMAGE="timescale/timescaledb:$(PREV_TS_VERSION)-pg$(PG_VER_NUMBER)$(PREV_EXTRA)"
1112
PREV_IMAGE=$(shell if docker pull $(PREV_TS_IMAGE) >/dev/null; then echo "$(PREV_TS_IMAGE)"; else echo "postgres:$(PG_VER_NUMBER)-alpine"; fi )
@@ -28,7 +29,8 @@ TAG_OSS=-t $(TAG_VERSION)-oss $(if $(PRE_RELEASE),,-t $(TAG_LATEST)-oss)
2829
DOCKER_BUILD_ARGS = --build-arg TS_VERSION=$(TS_VERSION) \
2930
--build-arg PG_VERSION=$(PG_VER_NUMBER) \
3031
--build-arg PREV_IMAGE=$(PREV_IMAGE) \
31-
--build-arg PG_CRON_VERSION=$(PG_CRON_VERSION)
32+
--build-arg PG_CRON_VERSION=$(PG_CRON_VERSION) \
33+
--build-arg POSTGIS_VERSION=$(POSTGIS_VERSION)
3234

3335

3436
default: image

bitnami/Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,58 @@ RUN set -e \
156156
/tmp/* \
157157
/var/tmp/*
158158

159+
# Add PostGIS Extension
160+
ARG POSTGIS_VERSION
161+
162+
RUN set -eux \
163+
&& apt update \
164+
&& apt install -y \
165+
ca-certificates \
166+
openssl \
167+
tar \
168+
wget \
169+
gettext \
170+
automake \
171+
libltdl-dev \
172+
libxml2-dev \
173+
libgeos-dev \
174+
libproj-dev \
175+
libprotobuf-c-dev \
176+
protobuf-c-compiler \
177+
g++\
178+
gcc \
179+
make \
180+
&& wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \
181+
&& mkdir -p /usr/src/postgis \
182+
&& tar \
183+
--extract \
184+
--file postgis.tar.gz \
185+
--directory /usr/src/postgis \
186+
--strip-components 1 \
187+
&& rm postgis.tar.gz \
188+
\
189+
# build PostGIS
190+
\
191+
&& cd /usr/src/postgis \
192+
&& gettextize \
193+
&& ./autogen.sh \
194+
&& ./configure \
195+
--with-pcredir="$(pcre-config --prefix)" --with-geosconfig="/usr/bin/geos-config"\
196+
&& make -j$(nproc) \
197+
&& make install \
198+
&& cd / \
199+
# clean
200+
&& apt-get autoremove --purge -y \
201+
wget \
202+
g++\
203+
gcc \
204+
make \
205+
&& apt-get clean -y \
206+
&& rm -rf \
207+
/var/lib/apt/lists/* \
208+
/tmp/* \
209+
/var/tmp/*
210+
159211
USER 1001
160212

161213
ENTRYPOINT [ "/opt/bitnami/scripts/postgresql/timescaledb-bitnami-entrypoint.sh" ]

bitnami/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ PG_VER=pg15
66
PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-)
77
PG_CRON_VERSION=v1.6.0
88
TS_VERSION=2.13.0
9+
POSTGIS_VERSION=3.4.1
910
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 = !!')
1011
PREV_TS_IMAGE="timescale/timescaledb:$(PREV_TS_VERSION)-pg$(PG_VER_NUMBER)-bitnami"
1112
PREV_IMAGE=$(shell if docker pull $(PREV_TS_IMAGE) >/dev/null; then echo "$(PREV_TS_IMAGE)"; else echo "bitnami/postgresql:$(PG_VER_NUMBER)"; fi )
@@ -25,7 +26,9 @@ TAG=-t $(TAG_VERSION) $(if $(PRE_RELEASE),,-t $(TAG_LATEST))
2526
DOCKER_BUILD_ARGS = --build-arg PG_VERSION=$(PG_VER_NUMBER) \
2627
--build-arg TS_VERSION=$(TS_VERSION) \
2728
--build-arg PREV_IMAGE=$(PREV_IMAGE) \
28-
--build-arg PG_CRON_VERSION=$(PG_CRON_VERSION)
29+
--build-arg PG_CRON_VERSION=$(PG_CRON_VERSION) \
30+
--build-arg POSTGIS_VERSION=$(POSTGIS_VERSION)
31+
2932

3033
default: image
3134

0 commit comments

Comments
 (0)