Skip to content

Instantly share code, notes, and snippets.

@ngosang
Created December 11, 2025 09:55
Show Gist options
  • Select an option

  • Save ngosang/7d1f31b7afd0bde41a1ef4b3d0630edb to your computer and use it in GitHub Desktop.

Select an option

Save ngosang/7d1f31b7afd0bde41a1ef4b3d0630edb to your computer and use it in GitHub Desktop.
Source code of Docker ngosang/timescaledb-postgis
# Author ngosang /@ hotmail [.es]
#
# Original source code
# https://github.com/timescale/timescaledb-docker/tree/9cfcb88c0fa9388cc60eb0bc79ea0a4d754f9938/postgis
#
# Steps to update:
# 1. Update the TimescaleDB base image
# https://hub.docker.com/r/timescale/timescaledb/tags
# 2. PosGIS Alpine build (check first link)
# https://github.com/postgis/docker-postgis/blob/master/18-3.6/alpine/Dockerfile
# https://hub.docker.com/r/postgis/postgis
# https://postgis.net/
FROM timescale/timescaledb:2.24.0-pg18
ENV POSTGIS_VERSION=3.6.1
ENV POSTGIS_SHA256=849391e75488a749663fbc8d63b846d063d387d286c04dea062820476f84c8f6
RUN set -eux \
&& apk add --no-cache --virtual .fetch-deps \
ca-certificates \
openssl \
tar \
\
&& wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \
&& echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \
&& 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 \
proj-util \
sfcgal-dev \
\
# The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains
# the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL.
# This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077
$DOCKER_PG_LLVM_DEPS \
\
autoconf \
automake \
cunit-dev \
file \
g++ \
gcc \
gettext-dev \
git \
json-c-dev \
libtool \
libxml2-dev \
make \
pcre2-dev \
perl \
protobuf-c-dev \
\
# build PostGIS - with Link Time Optimization (LTO) enabled
&& cd /usr/src/postgis \
&& gettextize \
&& ./autogen.sh \
&& ./configure \
--enable-lto \
&& make -j$(nproc) \
&& make install \
# add .postgis-rundeps
&& apk add --no-cache --virtual .postgis-rundeps \
\
gdal \
geos \
proj \
sfcgal \
\
json-c \
libstdc++ \
pcre2 \
protobuf-c \
\
# ca-certificates: for accessing remote raster files
# fix https://github.com/postgis/docker-postgis/issues/307
ca-certificates \
# clean
&& cd / \
&& rm -rf /usr/src/postgis \
&& apk del .fetch-deps .build-deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment