Skip to content

Commit c220059

Browse files
committed
Changed to timescale DB based image on ubuntu
1 parent 8978fdc commit c220059

1 file changed

Lines changed: 48 additions & 112 deletions

File tree

Dockerfile

Lines changed: 48 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,63 @@
11
# -----------------------------------------------------------------------------------------------
2-
# POST GIS image built for aarch64 support using alternative base image, copied from:
2+
# POSTGIS and TimescaleDB (inc. toolkit for hyperfunctions) image built for aarch64 support
3+
# using alpine base image.
4+
#
5+
# timescale/timescaledb-ha image is ubuntu based and only currently supports amd64; they are
6+
# working on ARM64 support in timescaledev/timescaledb-ha see:
37
#
4-
# https://github.com/postgis/docker-postgis/blob/master/14-3.2/alpine/Dockerfile
8+
# https://github.com/timescale/timescaledb-docker-ha/pull/355
59
#
6-
# See this issue for aarch64 support:
10+
# See this issue for POSTGIS base image aarch64 support discussion:
711
#
812
# https://github.com/postgis/docker-postgis/issues/216
9-
# -----------------------------------------------------------------------------------------------
10-
FROM postgres:14-alpine3.14
13+
# ------- ----------------------------------------------------------------------------------------
14+
15+
# TODO: Switch over to timescale/timescaledb-ha once arm64 supported
16+
# We get POSTGIS and timescale+toolkit from this image
17+
FROM timescaledev/timescaledb-ha:pg14-multi as trimmed
1118
MAINTAINER support@openremote.io
1219

13-
ENV POSTGIS_VERSION 3.2.0
14-
ENV POSTGIS_SHA256 c725d1be6d57ad199bbb6393cc3546defb70de1c78fe1787f7ccef2d51c3647b
20+
USER root
21+
22+
# Give postgres user the same UID and GID as the old alpine postgres image to simplify migration of existing DB
23+
RUN usermod -u 70 postgres \
24+
&& groupmod -g 70 postgres \
25+
&& (find / -group 1000 -exec chgrp -h postgres {} \; || true) \
26+
&& (find / -user 1000 -exec chown -h postgres {} \; || true)
27+
28+
29+
# Below is copied from https://github.com/timescale/timescaledb-docker-ha/blob/master/Dockerfile
30+
# to minimise the size of this image
31+
## Create a smaller Docker image from the builder image
32+
FROM scratch
33+
COPY --from=trimmed / /
1534

35+
ARG PG_MAJOR=14
36+
ENTRYPOINT ["/docker-entrypoint.sh"]
37+
CMD ["postgres"]
38+
39+
ENV PGROOT=/home/postgres \
40+
PGDATA=/home/postgres/pgdata/data \
41+
PGLOG=/home/postgres/pg_log \
42+
PGSOCKET=/home/postgres/pgdata \
43+
BACKUPROOT=/home/postgres/pgdata/backup \
44+
PGBACKREST_CONFIG=/home/postgres/pgdata/backup/pgbackrest.conf \
45+
PGBACKREST_STANZA=poddb \
46+
PATH=/usr/lib/postgresql/${PG_MAJOR}/bin:${PATH} \
47+
LC_ALL=C.UTF-8 \
48+
LANG=C.UTF-8 \
49+
# When having an interactive psql session, it is useful if the PAGER is disable
50+
PAGER=""
51+
52+
WORKDIR /home/postgres
53+
EXPOSE 5432 8008 8081
54+
USER postgres
55+
56+
## ADD OR convenience default ENV values and healthcheck
1657
ENV TZ ${TZ:-Europe/Amsterdam}
1758
ENV PGTZ ${PGTZ:-Europe/Amsterdam}
1859
ENV POSTGRES_DB ${POSTGRES_DB:-openremote}
1960
ENV POSTGRES_USER ${POSTGRES_USER:-postgres}
2061
ENV POSTGRES_PASSWORD ${POSTGRES_PASSWORD:-postgres}
21-
ENV PGUSER "$POSTGRES_USER"
22-
23-
#Temporary fix:
24-
# for PostGIS 2.* - building a special geos
25-
# reason: PostGIS 2.5.5 is not working with GEOS 3.9.*
26-
ENV POSTGIS2_GEOS_VERSION tags/3.8.2
27-
28-
RUN set -eux \
29-
\
30-
&& apk add --no-cache --virtual .fetch-deps \
31-
ca-certificates \
32-
openssl \
33-
tar \
34-
\
35-
&& wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/$POSTGIS_VERSION.tar.gz" \
36-
&& echo "$POSTGIS_SHA256 *postgis.tar.gz" | sha256sum -c - \
37-
&& mkdir -p /usr/src/postgis \
38-
&& tar \
39-
--extract \
40-
--file postgis.tar.gz \
41-
--directory /usr/src/postgis \
42-
--strip-components 1 \
43-
&& rm postgis.tar.gz \
44-
\
45-
&& apk add --no-cache --virtual .build-deps \
46-
autoconf \
47-
automake \
48-
clang-dev \
49-
file \
50-
g++ \
51-
gcc \
52-
gdal-dev \
53-
gettext-dev \
54-
json-c-dev \
55-
libtool \
56-
libxml2-dev \
57-
llvm11-dev \
58-
make \
59-
pcre-dev \
60-
perl \
61-
proj-dev \
62-
protobuf-c-dev \
63-
\
64-
# GEOS setup
65-
&& if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \
66-
apk add --no-cache --virtual .build-deps-geos geos-dev cunit-dev ; \
67-
elif [ $(printf %.1s "$POSTGIS_VERSION") == 2 ]; then \
68-
apk add --no-cache --virtual .build-deps-geos cmake git ; \
69-
cd /usr/src ; \
70-
git clone https://github.com/libgeos/geos.git ; \
71-
cd geos ; \
72-
git checkout ${POSTGIS2_GEOS_VERSION} -b geos_build ; \
73-
mkdir cmake-build ; \
74-
cd cmake-build ; \
75-
cmake -DCMAKE_BUILD_TYPE=Release .. ; \
76-
make -j$(nproc) ; \
77-
make check ; \
78-
make install ; \
79-
cd / ; \
80-
rm -fr /usr/src/geos ; \
81-
else \
82-
echo ".... unknown PosGIS ...." ; \
83-
fi \
84-
\
85-
# build PostGIS
86-
\
87-
&& cd /usr/src/postgis \
88-
&& gettextize \
89-
&& ./autogen.sh \
90-
&& ./configure \
91-
--with-pcredir="$(pcre-config --prefix)" \
92-
&& make -j$(nproc) \
93-
&& make install \
94-
\
95-
# regress check
96-
&& mkdir /tempdb \
97-
&& chown -R postgres:postgres /tempdb \
98-
&& su postgres -c 'pg_ctl -D /tempdb init' \
99-
&& su postgres -c 'pg_ctl -D /tempdb start' \
100-
&& cd regress \
101-
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \
102-
#&& make -j$(nproc) check RUNTESTFLAGS=--dumprestore PGUSER=postgres \
103-
#&& make garden PGUSER=postgres \
104-
&& su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \
105-
&& rm -rf /tempdb \
106-
&& rm -rf /tmp/pgis_reg \
107-
# add .postgis-rundeps
108-
&& apk add --no-cache --virtual .postgis-rundeps \
109-
gdal \
110-
json-c \
111-
libstdc++ \
112-
pcre \
113-
proj \
114-
protobuf-c \
115-
# Geos setup
116-
&& if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \
117-
apk add --no-cache --virtual .postgis-rundeps-geos geos ; \
118-
fi \
119-
# clean
120-
&& cd / \
121-
&& rm -rf /usr/src/postgis \
122-
&& apk del .fetch-deps .build-deps .build-deps-geos
123-
124-
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
125-
COPY ./update-postgis.sh /usr/local/bin
12662

12763
HEALTHCHECK --interval=3s --timeout=3s --start-period=2s --retries=30 CMD pg_isready

0 commit comments

Comments
 (0)