forked from postgis/docker-postgis
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.bundle0.template
452 lines (395 loc) · 15.6 KB
/
Dockerfile.bundle0.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
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# Experimental Geo Bundle package.
# This is a work in progress and not yet ready for production.
# Some packages will be removed from this bundle and others will be added.
# The goal is to have a bundle that includes all the most popular extensions with PostGIS
# set the base image , make build-* is overwriting with the actual value !
ARG REGISTRY={{ env.REGISTRY }}
ARG REPO_NAME={{ env.REPO_NAME }}
ARG IMAGE_NAME={{ env.IMAGE_NAME }}
ARG PGIS1_BASE_IMAGE=${REGISTRY}/${REPO_NAME}/${IMAGE_NAME}:{{ .[env.variant].PG_DOCKER }}-{{ .[env.variant].postgis }}-{{ env.variant }}
ARG PGIS1_MOBILITYDB_REPOSITORY=https://github.com/MobilityDB/MobilityDB.git
ARG PGIS1_MOBILITYDB_CHECKOUT={{ .[env.variant].MOBILITYDB_CHECKOUT }}
ARG PGIS1_MOBILITYDB_CHECKOUT_SHA1={{ .[env.variant].MOBILITYDB_CHECKOUT_SHA1 }}
ARG PGIS1_PGSQL_HTTP_REPOSITORY=https://github.com/pramsey/pgsql-http.git
ARG PGIS1_PGSQL_HTTP_CHECKOUT={{ .[env.variant].PGSQL_HTTP_CHECKOUT }}
ARG PGIS1_PGSQL_HTTP_CHECKOUT_SHA1={{ .[env.variant].PGSQL_HTTP_CHECKOUT_SHA1 }}
ARG PGIS1_PGSQL_GZIP_REPOSITORY=https://github.com/pramsey/pgsql-gzip.git
ARG PGIS1_PGSQL_GZIP_CHECKOUT={{ .[env.variant].PGSQL_GZIP_CHECKOUT }}
ARG PGIS1_PGSQL_GZIP_CHECKOUT_SHA1={{ .[env.variant].PGSQL_GZIP_CHECKOUT_SHA1 }}
ARG PGIS1_TIMESCALEDB_APACHE_ONLY=false
ARG PGIS1_TIMESCALEDB_REPOSITORY=https://github.com/timescale/timescaledb.git
ARG PGIS1_TIMESCALEDB_CHECKOUT={{ .[env.variant].TIMESCALEDB_CHECKOUT }}
ARG PGIS1_TIMESCALEDB_CHECKOUT_SHA1={{ .[env.variant].TIMESCALEDB_CHECKOUT_SHA1 }}
ARG PGIS1_PG_HINT_PLAN_REPOSITORY=https://github.com/ossc-db/pg_hint_plan.git
ARG PGIS1_PG_HINT_PLAN_CHECKOUT={{ .[env.variant].PG_HINT_PLAN_CHECKOUT }}
ARG PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1={{ .[env.variant].PG_HINT_PLAN_CHECKOUT_SHA1 }}
ARG PGIS1_DUCKDB_CHECKOUT={{ .[env.variant].DUCKDB_CHECKOUT }}
FROM ${PGIS1_BASE_IMAGE} AS builder
ARG PGIS1_DUCKDB_CHECKOUT
RUN set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
autoconf \
automake \
autotools-dev \
bison \
build-essential \
cmake \
curl \
flex \
g++ \
git \
make \
pgxnclient \
postgresql-server-dev-$PG_MAJOR \
unzip \
wget \
# MobilityDB
libgeos++-dev \
libgsl-dev \
libjson-c-dev \
libproj-dev \
# TimescaleDB
libkrb5-dev \
# pgsql-http
libcurl4-gnutls-dev \
# hydra (columnar)
liblz4-dev \
# pgsql-gzip
zlib1g-dev \
# sqlite_fdw
sqlite3 \
# plv8
ninja-build \
pkg-config \
# bytemagic
libmagic-dev \
# pgsoudium \
libsodium-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
FROM builder as builder-http-gzip
ARG PGIS1_PGSQL_HTTP_REPOSITORY
ARG PGIS1_PGSQL_HTTP_CHECKOUT
ARG PGIS1_PGSQL_HTTP_CHECKOUT_SHA1
ARG PGIS1_PGSQL_GZIP_REPOSITORY
ARG PGIS1_PGSQL_GZIP_CHECKOUT
ARG PGIS1_PGSQL_GZIP_CHECKOUT_SHA1
RUN set -eux \
&& mkdir -p /pgsql-gzip \
&& cd pgsql-gzip \
&& git init \
&& git remote add origin ${PGIS1_PGSQL_GZIP_REPOSITORY} \
&& git fetch --depth 1 origin ${PGIS1_PGSQL_GZIP_CHECKOUT} \
&& git checkout FETCH_HEAD \
# Verify that the commit hash matches the known good one
&& if [ "$(git rev-parse HEAD)" != "$PGIS1_PGSQL_GZIP_CHECKOUT_SHA1" ]; then exit 1; fi \
&& git log -1 > /_pgsql_gzip_last_commit.txt \
&& make -j$(nproc) \
&& make install
RUN set -eux \
&& mkdir -p /pgsql-http \
&& cd pgsql-http \
&& git init \
&& git remote add origin ${PGIS1_PGSQL_HTTP_REPOSITORY} \
&& git fetch --depth 1 origin ${PGIS1_PGSQL_HTTP_CHECKOUT} \
&& git checkout FETCH_HEAD \
# Verify that the commit hash matches the known good one
&& if [ "$(git rev-parse HEAD)" != "$PGIS1_PGSQL_HTTP_CHECKOUT_SHA1" ]; then exit 1; fi \
&& git log -1 > /_pgsql_http_last_commit.txt \
&& make -j$(nproc) \
&& make install
FROM builder as builder-timescaledb
ARG PGIS1_TIMESCALEDB_APACHE_ONLY
ARG PGIS1_TIMESCALEDB_REPOSITORY
ARG PGIS1_TIMESCALEDB_CHECKOUT
ARG PGIS1_TIMESCALEDB_CHECKOUT_SHA1
# Install TimescaleDB; no Arm64 apt support, so build from source
RUN set -eux \
&& mkdir -p /timescaledb \
&& cd timescaledb \
&& git init \
&& git remote add origin ${PGIS1_TIMESCALEDB_REPOSITORY} \
&& git fetch --depth 1 origin ${PGIS1_TIMESCALEDB_CHECKOUT} \
&& git checkout FETCH_HEAD \
# Verify that the commit hash matches the known good one
&& if [ "$(git rev-parse HEAD)" != "$PGIS1_TIMESCALEDB_CHECKOUT_SHA1" ]; then exit 1; fi \
&& git log -1 > /_timescaledb_last_commit.txt \
&& ./bootstrap \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DCMAKE_POLICY_DEFAULT_CMP0069=NEW \
\
-DAPACHE_ONLY=${PGIS1_TIMESCALEDB_APACHE_ONLY} \
-DREGRESS_CHECKS=OFF \
-DSEND_TELEMETRY_DEFAULT=NO \
-DTAP_CHECKS=OFF \
-DWARNINGS_AS_ERRORS=OFF \
-DENABLE_DEBUG_UTILS=OFF \
&& cd build \
&& make -j$(nproc) \
&& make install
FROM builder as builder-mobilitydb
ARG PGIS1_MOBILITYDB_REPOSITORY
ARG PGIS1_MOBILITYDB_CHECKOUT
ARG PGIS1_MOBILITYDB_CHECKOUT_SHA1
# Install MobilityDB
RUN set -eux \
&& mkdir -p /MobilityDB \
&& cd MobilityDB \
&& git init \
&& git remote add origin ${PGIS1_MOBILITYDB_REPOSITORY} \
&& git fetch --depth 1 origin ${PGIS1_MOBILITYDB_CHECKOUT} \
&& git checkout FETCH_HEAD \
# Verify that the commit hash matches the known good one
&& if [ "$(git rev-parse HEAD)" != "$PGIS1_MOBILITYDB_CHECKOUT_SHA1" ]; then exit 1; fi \
&& git log -1 > /_MobilityDB_last_commit.txt \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DCMAKE_POLICY_DEFAULT_CMP0069=NEW \
.. \
&& make -j$(nproc) \
&& make install
FROM builder as builder-pgxn
RUN pgxn install --verbose byteamagic
RUN pgxn install --verbose ddlx
RUN pgxn install --verbose dsef
RUN pgxn install --verbose json_accessors
RUN pgxn install --verbose lostgis
#RUN pgxn install --verbose parray_gin # not working on CircleCI arm .. yet
RUN pgxn install --verbose permuteseq
RUN pgxn install --verbose pg_curl # https://github.com/RekGRpth/pg_curl
RUN pgxn install --verbose pg_roaringbitmap
RUN pgxn install --verbose pg_rowalesce
RUN pgxn install --verbose pg_uuidv7
RUN pgxn install --verbose pg_xenophile
RUN pgxn install --verbose pg_xxhash
RUN pgxn install --verbose pgsodium
RUN pgxn install --verbose pgsql_tweaks
{{ if env.version | startswith("17") then ( -}}
# sqlite_fdw is not available for PG17
{{ ) else ( -}}
RUN USE_PGXS=1 pgxn install sqlite_fdw
{{ ) end -}}
FROM builder as builder-other
ARG PGIS1_PG_HINT_PLAN_REPOSITORY
ARG PGIS1_PG_HINT_PLAN_CHECKOUT
ARG PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1
{{ if env.version | startswith("17") then ( -}}
# hydradatabase/hydra is not available for PG17
{{ ) else ( -}}
# Add hydradatabase
RUN set -eux \
&& git clone --depth 1 https://github.com/hydradatabase/hydra \
&& cd hydra/columnar \
&& git checkout main \
&& export COLUMNAR_O3=1 \
&& ./configure \
&& make -j$(nproc) \
&& make install
{{ ) end -}}
# {{ if env.version | startswith("16") then ( -}}
# # pg_quack is not available for PG16
# # - https://github.com/hydradatabase/pg_quack/issues/3
# {{ ) else ( -}}
# # add pg_quack: PG 14 and PG 15 only (PG 16 is not yet supported)
# # TODO: add pg_quack version!
# RUN set -eux \
# && git clone --depth 1 https://github.com/hydradatabase/pg_quack \
# && cd pg_quack \
# && make -j$(nproc) \
# && make install
# {{ ) end -}}
# install pg_hint_plan
RUN set -eux \
&& mkdir pg_hint_plan \
&& cd pg_hint_plan \
&& git init \
&& git remote add origin ${PGIS1_PG_HINT_PLAN_REPOSITORY} \
&& git fetch --depth 1 origin ${PGIS1_PG_HINT_PLAN_CHECKOUT} \
&& git checkout FETCH_HEAD \
# Verify that the commit hash matches the known good one
&& if [ "$(git rev-parse HEAD)" != "$PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1" ]; then exit 1; fi \
&& make -j$(nproc) \
&& make install
RUN set -eux \
&& git clone --depth 1 https://github.com/NikolayS/postgres_dba.git \
&& cd postgres_dba \
&& rm -rf .git
RUN set -eux \
&& git clone --depth 1 https://github.com/dr-jts/pg_svg.git \
&& cd pg_svg \
&& rm -rf .git
#install: psql < /pg_svg/pg-svg-lib.sql
FROM ${REGISTRY}/${REPO_NAME}/${IMAGE_NAME}:{{ .[env.variant].PG_DOCKER }}-{{ .[env.variant].postgis }}-{{ env.variant }}
LABEL maintainer="PostGIS Project - https://postgis.net" \
org.opencontainers.image.description="PostGIS Bundle - {{ .[env.variant].PG_DOCKER }}-{{ .[env.variant].postgis }}-{{ env.variant }} " \
org.opencontainers.image.source="https://github.com/postgis/docker-postgis"
# install all utf8 locales;
# helping: https://github.com/docker-library/docs/tree/master/postgres#locale-customization
RUN set -eux \
&& sed -i -e 's/# \(.*\.UTF-8\)/\1/' /etc/locale.gen \
&& locale-gen
RUN set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
\
bzip2 \
curl \
jq \
unzip \
wget \
\
gdal-bin \
proj-bin \
sqlite3 \
\
pipx \
python-is-python3 \
python3 \
python3-geoalchemy2 \
python3-pglast \
python3-pip \
python3-psycopg2 \
python3-setuptools \
python3-sqlalchemy \
\
postgis \
postgresql \
postgresql-client-common \
postgresql-common \
postgresql-contrib \
postgresql-plpython3-$PG_MAJOR \
postgresql-postgis \
postgresql-postgis-scripts \
\
pg-activity \
pgbackrest \
pgbadger \
pgtap \
pgtop \
pspg \
vip-manager \
\
{{ if env.version | startswith("17") then ( -}}
#postgresql-$PG_MAJOR-age \ # not available for PG17
#postgresql-$PG_MAJOR-decoderbufs \ # not available for PG17
{{ ) else ( -}}
postgresql-$PG_MAJOR-age \
postgresql-$PG_MAJOR-decoderbufs \
{{ ) end -}}
\
postgresql-$PG_MAJOR-asn1oid \
postgresql-$PG_MAJOR-cron \
postgresql-$PG_MAJOR-extra-window-functions \
postgresql-$PG_MAJOR-first-last-agg \
postgresql-$PG_MAJOR-h3 \
postgresql-$PG_MAJOR-hll \
postgresql-$PG_MAJOR-hypopg \
postgresql-$PG_MAJOR-icu-ext \
postgresql-$PG_MAJOR-jsquery \
postgresql-$PG_MAJOR-numeral \
postgresql-$PG_MAJOR-ogr-fdw \
postgresql-$PG_MAJOR-partman \
postgresql-$PG_MAJOR-periods \
postgresql-$PG_MAJOR-pg-fact-loader \
postgresql-$PG_MAJOR-pg-failover-slots \
postgresql-$PG_MAJOR-pg-stat-kcache \
postgresql-$PG_MAJOR-pg-wait-sampling \
postgresql-$PG_MAJOR-pgaudit \
postgresql-$PG_MAJOR-pgl-ddl-deploy \
postgresql-$PG_MAJOR-pglogical \
postgresql-$PG_MAJOR-pgmp \
postgresql-$PG_MAJOR-pgpcre \
postgresql-$PG_MAJOR-pgq3 \
postgresql-$PG_MAJOR-pgrouting \
postgresql-$PG_MAJOR-pgrouting-scripts \
postgresql-$PG_MAJOR-pgsphere \
postgresql-$PG_MAJOR-pgtap \
postgresql-$PG_MAJOR-pgvector \
postgresql-$PG_MAJOR-pldebugger \
postgresql-$PG_MAJOR-plpgsql-check \
postgresql-$PG_MAJOR-pointcloud \
postgresql-$PG_MAJOR-prefix \
postgresql-$PG_MAJOR-prioritize \
postgresql-$PG_MAJOR-q3c \
postgresql-$PG_MAJOR-repack \
postgresql-$PG_MAJOR-rum \
postgresql-$PG_MAJOR-show-plans \
postgresql-$PG_MAJOR-squeeze \
# add MobilityDb missing dependency from libgsl-dev
libgsl27 \
# MeCab based tokenizer for pgdg-pgroonga
groonga-tokenizer-mecab \
# bytemagic
libmagic1 libmagic-mgc \
# pgsodium
libsodium23 \
\
&& rm -Rf /root/.cache/pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ARG PGIS1_DUCKDB_CHECKOUT
ENV PGIS1_DUCKDB_CHECKOUT=${PGIS1_DUCKDB_CHECKOUT}
RUN arch=$(uname -m) \
&& DUCKDB_VERSION=$(echo "$PGIS1_DUCKDB_CHECKOUT" | sed 's/tags\///') \
&& echo "DUCKDB_VERSION=${DUCKDB_VERSION}" \
&& echo "PGIS1_DUCKDB_CHECKOUT=${PGIS1_DUCKDB_CHECKOUT}" \
&& case "$arch" in \
x86_64) \
duck_binary="duckdb_cli-linux-amd64.zip" ;; \
aarch64) \
duck_binary="duckdb_cli-linux-aarch64.zip" ;; \
*) \
echo "Unsupported architecture: $arch"; exit 1 ;; \
esac \
&& wget https://github.com/duckdb/duckdb/releases/download/${DUCKDB_VERSION}/$duck_binary \
&& unzip $duck_binary -d /usr/local/bin \
&& rm $duck_binary \
&& duckdb --version
# install extensions
# https://duckdb.org/docs/extensions/overview.html
ENV DUCKDB_EXTENSIONS="arrow autocomplete excel fts httpfs icu inet json parquet postgres_scanner spatial sqlite_scanner substrait tpcds tpch visualizer"
RUN for e in ${DUCKDB_EXTENSIONS} ; do \
echo "Installing $e ..."; \
duckdb -c "INSTALL $e;"; \
echo "LOAD $e;" >> $HOME/.duckdbrc; \
done
# Install from stages
COPY --from=builder-http-gzip /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/
COPY --from=builder-http-gzip /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib
COPY --from=builder-mobilitydb /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/
COPY --from=builder-mobilitydb /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib
COPY --from=builder-timescaledb /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/
COPY --from=builder-timescaledb /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib
COPY --from=builder-pgxn /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/
COPY --from=builder-pgxn /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib
COPY --from=builder-other /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/
COPY --from=builder-other /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib
COPY --from=builder-other /postgres_dba /postgres_dba
COPY --from=builder-other /pg_svg /pg_svg
# check any missing dependencies
RUN set -eux \
&& ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true
# multiple LLVM existance is not optimal; so we give a warning.
# known problem: duplicated LLVM
RUN set -eux \
&& dpkg -l | grep llvm \
&& llvm_count=$(dpkg -l | grep llvm | wc -l) \
&& if [ "$llvm_count" -ne 1 ]; then \
echo "WARNING: More than one llvm package or none at all found!"; \
dpkg -l | grep llvm ; \
fi
# add MobilityDB requirements
RUN set -eux \
&& cp -v /usr/share/postgresql/postgresql.conf.sample /usr/share/postgresql/postgresql.conf.sample.orig; \
# add MobilityDB and TimescaleDB requirements
echo "shared_preload_libraries = 'pg_hint_plan,postgis-3,timescaledb,pg_cron,pg_stat_statements'" >> /usr/share/postgresql/postgresql.conf.sample; \
# MobilityDB recomendation
echo "max_locks_per_transaction = 128" >> /usr/share/postgresql/postgresql.conf.sample; \
echo "timescaledb.telemetry_level=off" >> /usr/share/postgresql/postgresql.conf.sample
# for postgres_dba Use ":dba" to see menu
RUN printf "%s %s %s %s\n" \\set dba \'\\\\i /postgres_dba/start.psql\' >> ~/.psqlrc
COPY ./initdb-bundle0.sh /docker-entrypoint-initdb.d/11_bundle0.sh