forked from postgis/docker-postgis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.alpine.template
129 lines (125 loc) · 4.37 KB
/
Dockerfile.alpine.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
FROM postgres:%%PG_MAJOR%%-alpine3.16
LABEL maintainer="PostGIS Project - https://postgis.net"
ENV POSTGIS_VERSION %%POSTGIS_VERSION%%
ENV POSTGIS_SHA256 %%POSTGIS_SHA256%%
RUN set -eux \
\
&& if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \
set -eux ; \
#
# using only v3.16
#
#GEOS: https://pkgs.alpinelinux.org/packages?name=geos&branch=v3.16 \
export GEOS_ALPINE_VER=3.10 ; \
#GDAL: https://pkgs.alpinelinux.org/packages?name=gdal&branch=v3.16 \
export GDAL_ALPINE_VER=3.5 ; \
#PROJ: https://pkgs.alpinelinux.org/packages?name=proj&branch=v3.16 \
export PROJ_ALPINE_VER=9.0 ; \
#
elif [ $(printf %.1s "$POSTGIS_VERSION") == 2 ]; then \
set -eux ; \
#
# using older branches v3.13; v3.14 for GEOS,GDAL,PROJ
#
#GEOS: https://pkgs.alpinelinux.org/packages?name=geos&branch=v3.13 \
export GEOS_ALPINE_VER=3.8 ; \
#GDAL: https://pkgs.alpinelinux.org/packages?name=gdal&branch=v3.14 \
export GDAL_ALPINE_VER=3.2 ; \
#PROJ: https://pkgs.alpinelinux.org/packages?name=proj&branch=v3.14 \
export PROJ_ALPINE_VER=7.2 ; \
#
\
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.14/main' >> /etc/apk/repositories ; \
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.14/community' >> /etc/apk/repositories ; \
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.13/main' >> /etc/apk/repositories ; \
echo 'https://dl-cdn.alpinelinux.org/alpine/v3.13/community' >> /etc/apk/repositories ; \
\
else \
set -eux ; \
echo ".... unknown \$POSTGIS_VERSION ...." ; \
exit 1 ; \
fi \
\
&& 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~=${GDAL_ALPINE_VER} \
geos-dev~=${GEOS_ALPINE_VER} \
proj-dev~=${PROJ_ALPINE_VER} \
\
autoconf \
automake \
clang-dev \
file \
g++ \
gcc \
gettext-dev \
json-c-dev \
libtool \
libxml2-dev \
llvm-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 \
\
# regress check
&& mkdir /tempdb \
&& chown -R postgres:postgres /tempdb \
&& su postgres -c 'pg_ctl -D /tempdb init' \
&& su postgres -c 'pg_ctl -D /tempdb start' \
&& cd regress \
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \
#&& make -j$(nproc) check RUNTESTFLAGS=--dumprestore PGUSER=postgres \
#&& make garden PGUSER=postgres \
\
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \
&& su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \
&& su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \
\
&& su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \
&& rm -rf /tempdb \
&& rm -rf /tmp/pgis_reg \
# add .postgis-rundeps
&& apk add --no-cache --virtual .postgis-rundeps \
\
gdal~=${GDAL_ALPINE_VER} \
geos~=${GEOS_ALPINE_VER} \
proj~=${PROJ_ALPINE_VER} \
\
json-c \
libstdc++ \
pcre \
protobuf-c \
# clean
&& cd / \
&& rm -rf /usr/src/postgis \
&& apk del .fetch-deps .build-deps \
# print PostGIS_Full_Version() for the log. ( experimental & internal )
&& cat /_pgis_full_version.txt
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
COPY ./update-postgis.sh /usr/local/bin