Skip to content

Commit

Permalink
Merge pull request #124 from PiyushRaj927/move_PostGIS
Browse files Browse the repository at this point in the history
add postgis extension with smoke test
  • Loading branch information
singhalkarun authored Feb 13, 2024
2 parents 7344e6a + 4d7b5ca commit 2bcc905
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ jobs:
echo "Test pg_cron Extension"
psql -c "CREATE EXTENSION pg_cron";
psql -c "SELECT cron.schedule('30 3 * * 6',\$\$DELETE FROM events WHERE event_time < now() - interval '1 week'\$\$)";
echo "Test PostGIS Extension"
psql -c "CREATE EXTENSION postgis;" || true
psql -c "SELECT PostGIS_Version();"
echo "Test PostGIS Geometry Function"
psql -c "CREATE TABLE test_geometry_table (id serial primary key, geom geometry(Point, 4326));"
psql -c "INSERT INTO test_geometry_table (geom) VALUES (ST_GeomFromText('POINT(0 0)', 4326));"
psql -c "SELECT * FROM test_geometry_table;"
break
fi
sleep 1
Expand Down
71 changes: 70 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,73 @@ RUN set -ex \
&& cd / \
&& rm /tmp/pg_cron.tar.gz \
&& rm -rf /tmp/pg_cron \
&& apk del .pg_cron-deps .pg_cron-build-deps
&& apk del .pg_cron-deps .pg_cron-build-deps

# Add PostGIS Extension
ARG POSTGIS_VERSION

RUN set -eux \
&& apk add --no-cache --virtual .fetch-deps \
ca-certificates \
openssl \
tar \
\
&& wget -O postgis.tar.gz "https:/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \
&& mkdir -p /usr/src/postgis \
&& tar \
--extract \
--file postgis.tar.gz \
--directory /usr/src/postgis \
--strip-components 1 \
&& rm postgis.tar.gz \
\
&& apk add --no-cache --virtual .build-deps \
\
gdal-dev \
geos-dev \
proj-dev \
autoconf \
automake \
clang15 \
cunit-dev \
file \
g++ \
gcc \
gettext-dev \
git \
json-c-dev \
libtool \
libxml2-dev \
llvm15-dev \
make \
pcre-dev \
perl \
protobuf-c-dev \
\
# build PostGIS
\
&& cd /usr/src/postgis \
&& gettextize \
&& ./autogen.sh \
&& ./configure \
--with-pcredir="$(pcre-config --prefix)" \
&& make -j$(nproc) \
&& make install \
\
# add .postgis-rundeps
&& apk add --no-cache --virtual .postgis-rundeps \
\
gdal \
geos \
proj \
\
json-c \
libstdc++ \
pcre \
protobuf-c \
\
ca-certificates \
# clean
&& cd / \
&& rm -rf /usr/src/postgis \
&& apk del .fetch-deps .build-deps
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PG_VER=pg15
PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-)
TS_VERSION=2.13.0
PG_CRON_VERSION=v1.6.0
POSTGIS_VERSION=3.4.1
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 = !!')
PREV_TS_IMAGE="timescale/timescaledb:$(PREV_TS_VERSION)-pg$(PG_VER_NUMBER)$(PREV_EXTRA)"
PREV_IMAGE=$(shell if docker pull $(PREV_TS_IMAGE) >/dev/null; then echo "$(PREV_TS_IMAGE)"; else echo "postgres:$(PG_VER_NUMBER)-alpine"; fi )
Expand All @@ -28,7 +29,8 @@ TAG_OSS=-t $(TAG_VERSION)-oss $(if $(PRE_RELEASE),,-t $(TAG_LATEST)-oss)
DOCKER_BUILD_ARGS = --build-arg TS_VERSION=$(TS_VERSION) \
--build-arg PG_VERSION=$(PG_VER_NUMBER) \
--build-arg PREV_IMAGE=$(PREV_IMAGE) \
--build-arg PG_CRON_VERSION=$(PG_CRON_VERSION)
--build-arg PG_CRON_VERSION=$(PG_CRON_VERSION) \
--build-arg POSTGIS_VERSION=$(POSTGIS_VERSION)


default: image
Expand Down
52 changes: 52 additions & 0 deletions bitnami/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,58 @@ RUN set -e \
/tmp/* \
/var/tmp/*

# Add PostGIS Extension
ARG POSTGIS_VERSION

RUN set -eux \
&& apt update \
&& apt install -y \
ca-certificates \
openssl \
tar \
wget \
gettext \
automake \
libltdl-dev \
libxml2-dev \
libgeos-dev \
libproj-dev \
libprotobuf-c-dev \
protobuf-c-compiler \
g++\
gcc \
make \
&& wget -O postgis.tar.gz "https:/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \
&& mkdir -p /usr/src/postgis \
&& tar \
--extract \
--file postgis.tar.gz \
--directory /usr/src/postgis \
--strip-components 1 \
&& rm postgis.tar.gz \
\
# build PostGIS
\
&& cd /usr/src/postgis \
&& gettextize \
&& ./autogen.sh \
&& ./configure \
--with-pcredir="$(pcre-config --prefix)" --with-geosconfig="/usr/bin/geos-config"\
&& make -j$(nproc) \
&& make install \
&& cd / \
# clean
&& apt-get autoremove --purge -y \
wget \
g++\
gcc \
make \
&& apt-get clean -y \
&& rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/*

USER 1001

ENTRYPOINT [ "/opt/bitnami/scripts/postgresql/timescaledb-bitnami-entrypoint.sh" ]
Expand Down
5 changes: 4 additions & 1 deletion bitnami/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PG_VER=pg15
PG_VER_NUMBER=$(shell echo $(PG_VER) | cut -c3-)
PG_CRON_VERSION=v1.6.0
TS_VERSION=2.13.0
POSTGIS_VERSION=3.4.1
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 = !!')
PREV_TS_IMAGE="timescale/timescaledb:$(PREV_TS_VERSION)-pg$(PG_VER_NUMBER)-bitnami"
PREV_IMAGE=$(shell if docker pull $(PREV_TS_IMAGE) >/dev/null; then echo "$(PREV_TS_IMAGE)"; else echo "bitnami/postgresql:$(PG_VER_NUMBER)"; fi )
Expand All @@ -25,7 +26,9 @@ TAG=-t $(TAG_VERSION) $(if $(PRE_RELEASE),,-t $(TAG_LATEST))
DOCKER_BUILD_ARGS = --build-arg PG_VERSION=$(PG_VER_NUMBER) \
--build-arg TS_VERSION=$(TS_VERSION) \
--build-arg PREV_IMAGE=$(PREV_IMAGE) \
--build-arg PG_CRON_VERSION=$(PG_CRON_VERSION)
--build-arg PG_CRON_VERSION=$(PG_CRON_VERSION) \
--build-arg POSTGIS_VERSION=$(POSTGIS_VERSION)


default: image

Expand Down

0 comments on commit 2bcc905

Please sign in to comment.