-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
120 lines (103 loc) · 2.79 KB
/
Dockerfile
File metadata and controls
120 lines (103 loc) · 2.79 KB
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
# syntax=docker/dockerfile:1
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
ARG POSTGIS_VERSION
ARG POSTGIS_SHA256
ARG TIMESCALEDB_VERSION
LABEL maintainer="Creowave Oy"
# Stop on errors and print commands
RUN set -eux
###########
# POSTGIS #
###########
# Install dependencies
RUN apk add --no-cache --virtual .postgis-fetch-deps \
ca-certificates \
openssl \
tar \
&& apk add --no-cache --virtual .postgis-build-deps \
gdal-dev \
geos-dev \
proj-dev \
proj-util \
sfcgal-dev \
clang \
llvm \
autoconf \
automake \
cunit-dev \
file \
g++ \
gcc \
gettext-dev \
git \
json-c-dev \
libtool \
libxml2-dev \
make \
pcre2-dev \
perl \
protobuf-c-dev \
&& apk add --no-cache --virtual .postgis-run-deps \
gdal \
geos \
proj \
sfcgal \
json-c \
libstdc++ \
pcre2 \
protobuf-c \
ca-certificates
# Create symlinks matching the LLVM paths hardcoded in PostgreSQL's PGXS build system
RUN PGXS_CLANG=$(grep '^CLANG' /usr/local/lib/postgresql/pgxs/src/Makefile.global | sed 's/.*= *//') \
&& PGXS_LLVM_BINPATH=$(grep '^LLVM_BINPATH' /usr/local/lib/postgresql/pgxs/src/Makefile.global | sed 's/.*= *//') \
&& echo "PGXS expects CLANG=${PGXS_CLANG}, LLVM_BINPATH=${PGXS_LLVM_BINPATH}" \
&& ln -sf /usr/bin/clang "/usr/bin/${PGXS_CLANG}" \
&& mkdir -p "${PGXS_LLVM_BINPATH}" \
&& ln -sf /usr/bin/llvm-lto "${PGXS_LLVM_BINPATH}/llvm-lto"
# Download, verify and extract PostGIS source code
RUN 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
# Build PostGIS
RUN cd /usr/src/postgis \
&& gettextize \
&& ./autogen.sh \
&& ./configure \
&& make -j$(nproc) \
&& make install
# Cleanup
RUN rm -rf /usr/src/postgis \
&& apk del .postgis-fetch-deps .postgis-build-deps
###############
# TIMESCALEDB #
###############
# Install dependencies
RUN apk add --no-cache --virtual .timescaledb-fetch-deps \
git \
&& apk add --no-cache --virtual .timescaledb-build-deps \
openssl-dev \
icu-dev \
clang \
gcc \
cmake \
make
# Clone TimescaleDB source code
RUN mkdir -p /usr/src/timescaledb \
&& git clone --depth 1 --branch "${TIMESCALEDB_VERSION}" https://github.com/timescale/timescaledb /usr/src/timescaledb
# Build and enable TimescaleDB
RUN cd /usr/src/timescaledb \
&& ./bootstrap \
&& cd build \
&& make \
&& make install \
&& sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" /usr/local/share/postgresql/postgresql.conf.sample
# Cleanup
RUN rm -rf /usr/src/timescaledb \
&& apk del .timescaledb-fetch-deps .timescaledb-build-deps