-
Notifications
You must be signed in to change notification settings - Fork 28
/
Dockerfile
417 lines (392 loc) · 12.1 KB
/
Dockerfile
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
ARG PG_VERSION
ARG PREV_IMAGE
ARG TS_VERSION
############################
# Build tools binaries in separate image
############################
ARG GO_VERSION=1.23
FROM golang:${GO_VERSION}-alpine AS tools
ENV TOOLS_VERSION 0.8.1
RUN apk update && apk add --no-cache git gcc musl-dev \
&& go install github.com/timescale/timescaledb-tune/cmd/timescaledb-tune@latest \
&& go install github.com/timescale/timescaledb-parallel-copy/cmd/timescaledb-parallel-copy@latest
############################
# Grab old versions from previous version
############################
ARG PG_VERSION
ARG PREV_IMAGE
FROM ${PREV_IMAGE} AS oldversions
# Remove update files, mock files, and all but the last 5 .so/.sql files
RUN rm -f $(pg_config --sharedir)/extension/timescaledb*mock*.sql \
&& if [ -f $(pg_config --pkglibdir)/timescaledb-tsl-1*.so ]; then rm -f $(ls -1 $(pg_config --pkglibdir)/timescaledb-tsl-1*.so | head -n -5); fi \
&& if [ -f $(pg_config --pkglibdir)/timescaledb-1*.so ]; then rm -f $(ls -1 $(pg_config --pkglibdir)/timescaledb-*.so | head -n -5); fi \
&& if [ -f $(pg_config --sharedir)/extension/timescaledb--1*.sql ]; then rm -f $(ls -1 $(pg_config --sharedir)/extension/timescaledb--1*.sql | head -n -5); fi
############################
# Now build image and copy in tools
############################
ARG PG_VERSION
FROM postgres:${PG_VERSION}-alpine3.18
ARG OSS_ONLY
LABEL maintainer="Timescale https://www.timescale.com"
COPY docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d/
COPY --from=tools /go/bin/* /usr/local/bin/
COPY --from=oldversions /usr/local/lib/postgresql/timescaledb-*.so /usr/local/lib/postgresql/
COPY --from=oldversions /usr/local/share/postgresql/extension/timescaledb--*.sql /usr/local/share/postgresql/extension/
ARG TS_VERSION
RUN set -ex \
&& apk add libssl1.1 \
&& apk add --no-cache --virtual .fetch-deps \
ca-certificates \
git \
openssl \
openssl-dev \
tar \
&& mkdir -p /build/ \
&& git clone https://github.com/timescale/timescaledb /build/timescaledb \
\
&& apk add --no-cache --virtual .build-deps \
coreutils \
dpkg-dev dpkg \
gcc \
krb5-dev \
libc-dev \
make \
cmake \
util-linux-dev \
\
# Build current version \
&& cd /build/timescaledb && rm -fr build \
&& git checkout ${TS_VERSION} \
&& ./bootstrap -DCMAKE_BUILD_TYPE=RelWithDebInfo -DREGRESS_CHECKS=OFF -DTAP_CHECKS=OFF -DGENERATE_DOWNGRADE_SCRIPT=ON -DWARNINGS_AS_ERRORS=OFF -DPROJECT_INSTALL_METHOD="docker"${OSS_ONLY} \
&& cd build && make install \
&& cd ~ \
\
&& if [ "${OSS_ONLY}" != "" ]; then rm -f $(pg_config --pkglibdir)/timescaledb-tsl-*.so; fi \
&& apk del .fetch-deps .build-deps \
&& rm -rf /build \
&& sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" /usr/local/share/postgresql/postgresql.conf.sample
# Update to shared_preload_libraries
RUN echo "shared_preload_libraries = 'citus,timescaledb,pg_cron,pgautofailover'" >> /usr/local/share/postgresql/postgresql.conf.sample
# Adding PG Vector
RUN cd /tmp
RUN apk add --no-cache --virtual .build-deps \
coreutils \
dpkg-dev dpkg \
gcc \
git \
krb5-dev \
libc-dev \
llvm15 \
clang \
clang15 \
make \
cmake \
util-linux-dev \
&& git clone --branch v0.7.0 https://github.com/pgvector/pgvector.git \
&& cd /pgvector \
&& ls \
&& make \
&& make install
# Adding pg_cron
ARG PG_CRON_VERSION
RUN set -ex \
&& cd /tmp\
&& apk add --no-cache --virtual .pg_cron-deps \
ca-certificates \
openssl \
tar \
&& apk add --no-cache --virtual .pg_cron-build-deps \
autoconf \
automake \
g++ \
clang15 \
llvm15 \
libtool \
libxml2-dev \
make \
perl \
&& wget -O pg_cron.tar.gz "https://github.com/citusdata/pg_cron/archive/refs/tags/${PG_CRON_VERSION}.tar.gz" \
&& mkdir -p /tmp/pg_cron \
&& tar \
--extract \
--file pg_cron.tar.gz \
--directory /tmp/pg_cron \
--strip-components 1 \
&& cd /tmp/pg_cron \
&& make \
&& make install \
# clean
&& cd / \
&& rm /tmp/pg_cron.tar.gz \
&& rm -rf /tmp/pg_cron \
&& 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://github.com/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
## Adding Citus
ARG CITUS_VERSION
# Install Citus dependencies
RUN set -ex \
&& apk add --no-cache --virtual .citus-deps \
curl \
jq \
# Install Citus
&& apk add --no-cache --virtual .citus-build-deps \
gcc \
libc-dev \
make \
curl-dev \
lz4-dev \
zstd-dev \
clang15 \
krb5-dev \
icu-dev \
libxslt-dev \
libxml2-dev \
llvm15-dev \
&& CITUS_DOWNLOAD_URL="https://github.com/citusdata/citus/archive/refs/tags/v${CITUS_VERSION}.tar.gz" \
&& curl -L -o /tmp/citus.tar.gz "${CITUS_DOWNLOAD_URL}" \
&& tar -C /tmp -xvf /tmp/citus.tar.gz \
&& chown -R postgres:postgres /tmp/citus-${CITUS_VERSION} \
&& cd /tmp/citus-${CITUS_VERSION} \
&& PATH="/usr/local/pgsql/bin:$PATH" ./configure \
&& make \
&& make install \
&& cd ~ \
&& rm -rf /tmp/citus.tar.gz /tmp/citus-${CITUS_VERSION} \
&& apk del .citus-deps .citus-build-deps
## Adding pg_repack
ARG PG_REPACK_VERSION
RUN set -eux \
&& apk add --no-cache --virtual .pg_repack-build-deps \
openssl-dev \
zstd-dev \
lz4-dev \
zlib-dev \
make \
clang15 \
gawk \
llvm15 \
gcc \
musl-dev \
# build pg_repack
&& wget -O /tmp/pg_repack-${PG_REPACK_VERSION}.zip "https://api.pgxn.org/dist/pg_repack/${PG_REPACK_VERSION}/pg_repack-${PG_REPACK_VERSION}.zip" \
&& unzip /tmp/pg_repack-${PG_REPACK_VERSION}.zip -d /tmp \
&& cd /tmp/pg_repack-${PG_REPACK_VERSION} \
&& make \
&& make install \
# clean
&& cd / \
&& rm -rf /tmp/pg_repack-${PG_REPACK_VERSION} /tmp/pg_repack.zip \
&& apk del .pg_repack-build-deps
# Adding pgautofailover
ARG PG_AUTO_FAILOVER_VERSION
RUN set -eux \
&& apk add --no-cache --virtual .pg_auto_failover-build-deps \
make \
gcc \
musl-dev \
krb5-dev \
openssl-dev \
clang15 \
ncurses-dev \
linux-headers \
zstd-dev \
lz4-dev \
zlib-dev \
libedit-dev \
libxml2-utils \
libxslt-dev \
llvm15 \
# build pg_auto_failover
&& wget -O /tmp/pg_auto_failover-${PG_AUTO_FAILOVER_VERSION}.zip "https://github.com/hapostgres/pg_auto_failover/archive/refs/tags/v${PG_AUTO_FAILOVER_VERSION}.zip" \
&& unzip /tmp/pg_auto_failover-${PG_AUTO_FAILOVER_VERSION}.zip -d /tmp \
&& ls -alh /tmp \
&& cd /tmp/pg_auto_failover-${PG_AUTO_FAILOVER_VERSION} \
&& make \
&& make install \
# clean
&& cd / \
&& rm -rf /tmp/pg_auto_failove-${PG_AUTO_FAILOVER_VERSION} /tmp/pg_auto_failove-${PG_AUTO_FAILOVER_VERSION}.zip \
&& apk del .pg_auto_failover-build-deps
## Adding postgresql-hll
ARG POSTGRES_HLL_VERSION
RUN set -eux \
&& apk add --no-cache --virtual .postgresql-hll-build-deps \
openssl-dev \
zstd-dev \
lz4-dev \
zlib-dev \
make \
git \
clang15 \
gawk \
llvm15 \
g++ \
musl-dev \
# build postgresql-hll
&& wget -O /tmp/postgresql-hll-${POSTGRES_HLL_VERSION}.zip "https://github.com/citusdata/postgresql-hll/archive/refs/tags/v${POSTGRES_HLL_VERSION}.zip" \
&& unzip /tmp/postgresql-hll-${POSTGRES_HLL_VERSION}.zip -d /tmp \
&& cd /tmp/postgresql-hll-${POSTGRES_HLL_VERSION} \
&& make \
&& make install \
# clean
&& cd / \
&& rm -rf /tmp/postgresql-hll-${POSTGRES_HLL_VERSION} /tmp/postgresql-hll-${POSTGRES_HLL_VERSION}.zip \
&& apk del .postgresql-hll-build-deps
# Install pg_jobmon
ARG PG_JOBMON_VERSION
RUN set -e \
\
&& apk add --no-cache --virtual .pg_jobmon-deps \
ca-certificates \
openssl \
tar \
\
&& cd /tmp\
&& wget -O pg_jobmon.tar.gz "https://github.com/omniti-labs/pg_jobmon/archive/v$PG_JOBMON_VERSION.tar.gz" \
&& mkdir -p /tmp/pg_jobmon \
&& tar \
--extract \
--file pg_jobmon.tar.gz \
--directory /tmp/pg_jobmon \
--strip-components 1 \
\
&& apk add --no-cache --virtual .pg_jobmon-build-deps \
autoconf \
automake \
g++ \
clang15 \
llvm15 \
libtool \
libxml2-dev \
make \
perl \
&& cd /tmp/pg_jobmon \
&& ls -alh . \
&& make \
&& make install \
&& cd / \
&& apk del .pg_jobmon-deps .pg_jobmon-build-deps \
&& rm -rf /tmp/pg_jobmon \
&& rm /tmp/pg_jobmon.tar.gz
# Adding pg_partman
ARG PG_PARTMAN_VERSION
RUN set -e \
&& cd /tmp\
&& apk add --no-cache --virtual .pg_partman-deps \
ca-certificates \
openssl \
tar \
&& apk add --no-cache --virtual .pg_partman-build-deps \
autoconf \
automake \
g++ \
clang15 \
llvm15 \
libtool \
libxml2-dev \
make \
perl \
&& wget -O pg_partman.tar.gz "https://github.com/pgpartman/pg_partman/archive/v$PG_PARTMAN_VERSION.tar.gz" \
&& mkdir -p /tmp/pg_partman \
&& tar \
--extract \
--file pg_partman.tar.gz \
--directory /tmp/pg_partman \
--strip-components 1 \
&& cd /tmp/pg_partman \
&& make \
&& make install \
# clean
&& cd / \
&& rm /tmp/pg_partman.tar.gz \
&& rm -rf /tmp/pg_partman \
&& apk del .pg_partman-deps .pg_partman-build-deps
ENV RUSTFLAGS="-C target-feature=-crt-static"
ARG PG_BESTMATCH_RS_SHA
ARG PG_VERSION
RUN set -x && apk add --no-cache --virtual .pg_bestmatch-build-deps \
git \
curl \
build-base \
clang \
llvm \
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& export PATH="$HOME/.cargo/bin:$PATH" \
&& rustup update stable \
&& cd /tmp && git clone --branch main https://github.com/tensorchord/pg_bestmatch.git \
&& ls -alh \
&& cd pg_bestmatch \
&& git checkout ${PG_BESTMATCH_RS_SHA} \
&& export PATH="$HOME/.cargo/bin:$PATH" \
&& cargo install --locked cargo-pgrx --version 0.12.0-alpha.1 \
&& cargo pgrx init --pg${PG_VERSION}=$(which pg_config) \
&& cargo pgrx install --release \
&& cd .. \
&& rm -rf ./pg_bestmatch \
&& apk del .pg_bestmatch-build-deps