forked from postgis/docker-postgis
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile.master.template
753 lines (701 loc) · 24.7 KB
/
Dockerfile.master.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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
# "Experimental"; solely for testing purposes. Anticipate frequent changes!
# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05.
ARG PGIS1_BASE_IMAGE=postgres:{{ .[env.variant].PG_DOCKER }}-{{ env.variant }}
ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git
ARG PGIS1_GEOS_REPOSITORY=https://github.com/libgeos/geos.git
ARG PGIS1_GDAL_REPOSITORY=https://github.com/OSGeo/gdal.git
ARG PGIS1_PROJ_REPOSITORY=https://github.com/OSGeo/PROJ.git
ARG PGIS1_SFCGAL_REPOSITORY=https://gitlab.com/sfcgal/SFCGAL.git
ARG PGIS1_CGAL_REPOSITORY=https://github.com/CGAL/cgal.git
# Should valid git checkout ( SHA1, tags, branches )
ARG PGIS1_POSTGIS_CHECKOUT={{ .[env.variant].POSTGIS_CHECKOUT }}
ARG PGIS1_GEOS_CHECKOUT={{ .[env.variant].GEOS_CHECKOUT }}
ARG PGIS1_GDAL_CHECKOUT={{ .[env.variant].GDAL_CHECKOUT }}
ARG PGIS1_PROJ_CHECKOUT={{ .[env.variant].PROJ_CHECKOUT }}
ARG PGIS1_SFCGAL_CHECKOUT={{ .[env.variant].SFCGAL_CHECKOUT }}
ARG PGIS1_CGAL_CHECKOUT={{ .[env.variant].CGAL_CHECKOUT }}
# Skip SHA1 check if PGIS1_*_CHECKOUT_SHA1 is empty or 'nocheck'
# Otherwise, verify that the commit hash matches
ARG PGIS1_POSTGIS_CHECKOUT_SHA1={{ .[env.variant].POSTGIS_CHECKOUT_SHA1 }}
ARG PGIS1_GEOS_CHECKOUT_SHA1={{ .[env.variant].GEOS_CHECKOUT_SHA1 }}
ARG PGIS1_GDAL_CHECKOUT_SHA1={{ .[env.variant].GDAL_CHECKOUT_SHA1 }}
ARG PGIS1_PROJ_CHECKOUT_SHA1={{ .[env.variant].PROJ_CHECKOUT_SHA1 }}
ARG PGIS1_SFCGAL_CHECKOUT_SHA1={{ .[env.variant].SFCGAL_CHECKOUT_SHA1 }}
ARG PGIS1_CGAL_CHECKOUT_SHA1={{ .[env.variant].CGAL_CHECKOUT_SHA1 }}
ARG PGIS1_BOOST_VERSION={{ .[env.variant].BOOST_VERSION }}
ARG PGIS1_CMAKE_BUILD_TYPE=Release
ARG PGIS1_GDAL_BUILD={{ .[env.variant].GDAL_BUILD }}
{{ if .[env.variant].GDAL_BUILD != "minimal" then ( -}}
# Full GDAL build ; with arrow, parquet and extra dependencies
{{ ) else ( -}}
# Minimal GDAL build ; no arrow, no parquet, no extra dependencies
{{ ) end -}}
FROM ${PGIS1_BASE_IMAGE} as builder
WORKDIR /
ARG PGIS1_BOOST_VERSION
ENV PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION}
# apt-get install
RUN set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
libboost-atomic${PGIS1_BOOST_VERSION} \
libboost-chrono${PGIS1_BOOST_VERSION} \
libboost-date-time${PGIS1_BOOST_VERSION} \
libboost-filesystem${PGIS1_BOOST_VERSION} \
libboost-program-options${PGIS1_BOOST_VERSION} \
libboost-serialization${PGIS1_BOOST_VERSION} \
libboost-system${PGIS1_BOOST_VERSION} \
libboost-test${PGIS1_BOOST_VERSION} \
libboost-thread${PGIS1_BOOST_VERSION} \
libboost-timer${PGIS1_BOOST_VERSION} \
libcurl3-gnutls \
libexpat1 \
libgmp10 \
libgmpxx4ldbl \
libjson-c5 \
libmpfr6 \
libprotobuf-c1 \
{{ if env.variant != "bullseye" then ( -}}
libtiff6 \
{{ ) else ( -}}
libtiff5 \
{{ ) end -}}
libxml2 \
sqlite3 \
# build dependency
autoconf \
automake \
autotools-dev \
bison \
build-essential \
ca-certificates \
cmake \
g++ \
git \
libboost-all-dev \
libcurl4-gnutls-dev \
libgmp-dev \
libjson-c-dev \
libmpfr-dev \
libpcre3-dev \
libpq-dev \
libprotobuf-c-dev \
libsqlite3-dev \
libtiff-dev \
libtool \
libxml2-dev \
make \
pkg-config \
protobuf-c-compiler \
xsltproc \
# gdal+
liblz4-dev \
liblzma-dev \
libwebp-dev \
libzstd-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ARG PGIS1_CMAKE_BUILD_TYPE
ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE}
FROM builder as cgal-sfcgal-builder
# cgal & sfcgal
ARG PGIS1_SFCGAL_REPOSITORY
ENV PGIS1_SFCGAL_REPOSITORY ${PGIS1_SFCGAL_REPOSITORY}
ARG PGIS1_SFCGAL_CHECKOUT
ENV PGIS1_SFCGAL_CHECKOUT ${PGIS1_SFCGAL_CHECKOUT}
ARG PGIS1_SFCGAL_CHECKOUT_SHA1
ARG PGIS1_CGAL_REPOSITORY
ENV PGIS1_CGAL_REPOSITORY ${PGIS1_CGAL_REPOSITORY}
ARG PGIS1_CGAL_CHECKOUT
ENV PGIS1_CGAL_CHECKOUT ${PGIS1_CGAL_CHECKOUT}
ARG PGIS1_CGAL_CHECKOUT_SHA1
RUN set -eux \
&& cd /usr/src \
&& mkdir cgal \
&& cd cgal \
&& git init \
&& git remote add origin ${PGIS1_CGAL_REPOSITORY} \
&& git fetch --depth 1 origin ${PGIS1_CGAL_CHECKOUT} \
&& git checkout FETCH_HEAD \
# Skip SHA1 check if PGIS1_CGAL_CHECKOUT_SHA1 is empty or 'nocheck'
# Otherwise, verify that the commit hash matches PGIS1_CGAL_CHECKOUT_SHA1
&& if [ -z "${PGIS1_CGAL_CHECKOUT_SHA1}" ] \
|| [ "${PGIS1_CGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \
echo "Skipping CGAL SHA1 check"; \
else \
if [ "$(git rev-parse HEAD)" != "${PGIS1_CGAL_CHECKOUT_SHA1}" ]; then \
echo "CGAL SHA1 problem! Stop!"; \
exit 1; \
fi; \
fi \
&& git log -1 > /_pgis_cgal_last_commit.txt \
&& cd /usr/src \
&& mkdir SFCGAL \
&& cd SFCGAL \
&& git init \
&& git remote add origin ${PGIS1_SFCGAL_REPOSITORY} \
&& git fetch --depth 1 origin ${PGIS1_SFCGAL_CHECKOUT} \
&& git checkout FETCH_HEAD \
# Skip SHA1 check if PGIS1_SFCGAL_CHECKOUT_SHA1 is empty or 'nocheck'
# Otherwise, verify that the commit hash matches PGIS1_SFCGAL_CHECKOUT_SHA1
&& if [ -z "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ] \
|| [ "${PGIS1_SFCGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \
echo "Skipping SFCGAL SHA1 check"; \
else \
if [ "$(git rev-parse HEAD)" != "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ]; then \
echo "SFCGAL SHA1 problem! Stop!"; \
exit 1; \
fi; \
fi \
&& git log -1 > /_pgis_sfcgal_last_commit.txt \
&& mkdir cmake-build \
&& cd cmake-build \
&& cmake .. \
-DCGAL_DIR=/usr/src/cgal \
-DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \
-DSFCGAL_BUILD_BENCH=OFF \
-DSFCGAL_BUILD_EXAMPLES=OFF \
-DSFCGAL_BUILD_TESTS=OFF \
-DSFCGAL_WITH_OSG=OFF \
&& make -j$(nproc) \
&& make install \
# clean
&& rm -fr /usr/src/SFCGAL \
&& rm -fr /usr/src/cgal
FROM builder as proj-builder
# proj
ARG PGIS1_PROJ_REPOSITORY
ENV PGIS1_PROJ_REPOSITORY ${PGIS1_PROJ_REPOSITORY}
ARG PGIS1_PROJ_CHECKOUT
ENV PGIS1_PROJ_CHECKOUT ${PGIS1_PROJ_CHECKOUT}
ARG PGIS1_PROJ_CHECKOUT_SHA1
RUN set -eux \
&& cd /usr/src \
&& mkdir PROJ \
&& cd PROJ \
&& git init \
&& git remote add origin ${PGIS1_PROJ_REPOSITORY} \
&& git fetch --depth 1 origin ${PGIS1_PROJ_CHECKOUT} \
&& git checkout FETCH_HEAD \
# Skip SHA1 check if PGIS1_PROJ_CHECKOUT_SHA1 is empty or 'nocheck'
# Otherwise, verify that the commit hash matches PGIS1_PROJ_CHECKOUT_SHA1
&& if [ -z "${PGIS1_PROJ_CHECKOUT_SHA1}" ] \
|| [ "${PGIS1_PROJ_CHECKOUT_SHA1}" = "nocheck" ]; then \
echo "Skipping PROJ SHA1 check"; \
else \
if [ "$(git rev-parse HEAD)" != "${PGIS1_PROJ_CHECKOUT_SHA1}" ]; then \
echo "PROJ SHA1 problem! Stop!"; \
exit 1; \
fi; \
fi \
&& git log -1 > /_pgis_proj_last_commit.txt \
# check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027
&& if [ -f "autogen.sh" ] ; then \
set -eux \
&& echo "autotools version: 'autogen.sh' exists! Older version!" \
&& ./autogen.sh \
&& ./configure --disable-static \
&& make -j$(nproc) \
&& make install \
; \
else \
set -eux \
&& echo "cmake version: 'autogen.sh' does not exists! Newer version!" \
&& mkdir build \
&& cd build \
&& cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \
&& make -j$(nproc) \
&& make install \
; \
fi \
\
&& rm -fr /usr/src/PROJ
FROM builder as geos-builder
# geos
ARG PGIS1_GEOS_REPOSITORY
ENV PGIS1_GEOS_REPOSITORY ${PGIS1_GEOS_REPOSITORY}
ARG PGIS1_GEOS_CHECKOUT
ENV PGIS1_GEOS_CHECKOUT ${PGIS1_GEOS_CHECKOUT}
ARG PGIS1_GEOS_CHECKOUT_SHA1
RUN set -eux \
&& cd /usr/src \
&& mkdir geos \
&& cd geos \
&& git init \
&& git remote add origin ${PGIS1_GEOS_REPOSITORY} \
&& git fetch --depth 1 origin ${PGIS1_GEOS_CHECKOUT} \
&& git checkout FETCH_HEAD \
# Skip SHA1 check if PGIS1_GEOS_CHECKOUT_SHA1 is empty or 'nocheck'
# Otherwise, verify that the commit hash matches PGIS1_GEOS_CHECKOUT_SHA1
&& if [ -z "${PGIS1_GEOS_CHECKOUT_SHA1}" ] \
|| [ "${PGIS1_GEOS_CHECKOUT_SHA1}" = "nocheck" ]; then \
echo "Skipping GEOS SHA1 check"; \
else \
if [ "$(git rev-parse HEAD)" != "${PGIS1_GEOS_CHECKOUT_SHA1}" ]; then \
echo "GEOS SHA1 problem! Stop!"; \
exit 1; \
fi; \
fi \
&& git log -1 > /_pgis_geos_last_commit.txt \
&& mkdir cmake-build \
&& cd cmake-build \
&& cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \
&& make -j$(nproc) \
&& make install \
&& cd / \
&& rm -fr /usr/src/geos
FROM builder as stage0-builder
COPY --from=cgal-sfcgal-builder /_pgis*.* /
COPY --from=cgal-sfcgal-builder /usr/local /usr/local
COPY --from=proj-builder /_pgis*.* /
COPY --from=proj-builder /usr/local /usr/local
COPY --from=geos-builder /_pgis*.* /
COPY --from=geos-builder /usr/local /usr/local
# gdal
ARG PGIS1_GDAL_REPOSITORY
ENV PGIS1_GDAL_REPOSITORY ${PGIS1_GDAL_REPOSITORY}
ARG PGIS1_GDAL_CHECKOUT
ENV PGIS1_GDAL_CHECKOUT ${PGIS1_GDAL_CHECKOUT}
ARG PGIS1_GDAL_CHECKOUT_SHA1
{{ if .[env.variant].GDAL_BUILD != "minimal" then ( -}}
# Install Arrow C++
# also check the "Build final image" section too, for the final installation
RUN set -eux \
# add backports \
&& apt-get update \
&& apt install -y -V ca-certificates wget \
&& wget https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-{{ env.variant }}.deb \
&& apt-get install -y -V ./apache-arrow-apt-source-latest-{{ env.variant }}.deb \
&& apt-get update \
# Automatically determine the latest PGIS1 Arrow version and SOVERSION
&& apt-cache showpkg libarrow-dev \
&& PGIS1_ARROW_VERSION=$(apt-cache showpkg libarrow-dev | grep -m1 'Versions:' -A1 | tail -n1 | grep -oP '^\S+') \
&& apt-cache depends libarrow-dev=${PGIS1_ARROW_VERSION} | tee /_pgis1_libarrow-dev-dependencies.txt \
&& PGIS1_ARROW_SOVERSION=$(grep 'Depends: libarrow' /_pgis1_libarrow-dev-dependencies.txt | grep -oP 'libarrow\K[0-9]+') \
&& echo "Detected PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" \
&& echo "Detected PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \
# Backup the version variables - reusing in a later stage
&& echo "PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" > /_pgis1_arrow_environment.env \
&& echo "PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" >> /_pgis1_arrow_environment.env \
# Install Arrow C++
&& apt-get install -y --no-install-recommends \
libarrow${PGIS1_ARROW_SOVERSION} \
libparquet${PGIS1_ARROW_SOVERSION} \
libarrow-dataset${PGIS1_ARROW_SOVERSION} \
libarrow-dev=${PGIS1_ARROW_VERSION} \
libparquet-dev=${PGIS1_ARROW_VERSION} \
libarrow-acero-dev=${PGIS1_ARROW_VERSION} \
libarrow-dataset-dev=${PGIS1_ARROW_VERSION} \
\
libblosc-dev \
libcfitsio-dev \
libfreexl-dev \
libfyba-dev \
libhdf5-dev \
libheif-dev \
libkml-dev \
libnetcdf-dev \
libopenjp2-7-dev \
libpng-dev \
libqhull-dev \
libspatialite-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
{{ ) else ( -}}
#
{{ ) end -}}
## GDAL_build-end
RUN set -eux \
&& ldconfig \
&& cd /usr/src \
&& mkdir gdal \
&& cd gdal \
&& git init \
&& git remote add origin ${PGIS1_GDAL_REPOSITORY} \
&& git fetch --depth 1 origin ${PGIS1_GDAL_CHECKOUT} \
&& git checkout FETCH_HEAD \
# Skip SHA1 check if PGIS1_GDAL_CHECKOUT_SHA1 is empty or 'nocheck'
# Otherwise, verify that the commit hash matches PGIS1_GDAL_CHECKOUT_SHA1
&& if [ -z "${PGIS1_GDAL_CHECKOUT_SHA1}" ] \
|| [ "${PGIS1_GDAL_CHECKOUT_SHA1}" = "nocheck" ]; then \
echo "Skipping GDAL SHA1 check"; \
else \
if [ "$(git rev-parse HEAD)" != "${PGIS1_GDAL_CHECKOUT_SHA1}" ]; then \
echo "GDAL SHA1 problem! Stop!"; \
exit 1; \
fi; \
fi \
&& git log -1 > /_pgis_gdal_last_commit.txt \
\
# gdal project directory structure - has been changed !
&& if [ -d "gdal" ] ; then \
echo "Directory 'gdal' dir exists -> older version!" ; \
cd gdal ; \
else \
echo "Directory 'gdal' does not exists! Newer version! " ; \
fi \
\
&& if [ -f "./autogen.sh" ]; then \
# Building with autoconf ( old/deprecated )
set -eux \
&& ./autogen.sh \
&& ./configure --disable-static \
; \
else \
# Building with cmake
set -eux \
&& mkdir build \
&& cd build \
# config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules
&& cmake .. \
-DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \
-DBUILD_TESTING=OFF \
-DBUILD_DOCS=OFF \
\
-DGDAL_HIDE_INTERNAL_SYMBOLS=ON \
-DRENAME_INTERNAL_TIFF_SYMBOLS=ON \
-DGDAL_USE_CURL=ON \
-DGDAL_USE_DEFLATE=ON \
-DGDAL_USE_EXPAT=ON \
-DGDAL_USE_GEOS=ON \
-DGDAL_USE_JSONC=ON \
-DGDAL_USE_LIBLZMA=ON \
-DGDAL_USE_LIBXML2=ON \
-DGDAL_USE_LZ4=ON \
-DGDAL_USE_POSTGRESQL=ON \
-DGDAL_USE_SQLITE3=ON \
-DGDAL_USE_TIFF=ON \
-DGDAL_USE_WEBP=ON \
-DGDAL_USE_ZLIB=ON \
-DGDAL_USE_ZSTD=ON \
{{ if .[env.variant].GDAL_BUILD != "minimal" then ( -}}
\
-DGDAL_USE_ARROW=ON \
-DGDAL_USE_ARROWDATASET=ON \
-DGDAL_USE_BLOSC=ON \
-DGDAL_USE_CFITSIO=ON \
-DGDAL_USE_FREEXL=ON \
-DGDAL_USE_FYBA=ON \
-DGDAL_USE_HDF5=ON \
-DGDAL_USE_HEIF=ON \
-DGDAL_USE_LERC_INTERNAL=ON \
-DGDAL_USE_LIBKML=ON \
-DGDAL_USE_NETCDF=ON \
-DGDAL_USE_OPENJPEG=ON \
-DGDAL_USE_PARQUET=ON \
-DGDAL_USE_PNG=ON \
-DGDAL_USE_QHULL=ON \
-DGDAL_USE_SPATIALITE=ON \
{{ ) else ( -}}
# minimal GDAL build ..
{{ ) end -}}
; \
fi \
\
&& make -j$(nproc) \
&& make install \
&& cd / \
&& rm -fr /usr/src/gdal
# Minimal command line test.
RUN set -eux \
&& ldconfig \
&& cs2cs \
&& ldd $(which gdalinfo) \
&& gdalinfo --version \
&& geos-config --version \
&& ogr2ogr --version \
&& proj \
&& sfcgal-config --version \
&& pcre-config --version
# -------------------------------------------
# final stage
# -------------------------------------------
FROM ${PGIS1_BASE_IMAGE}
LABEL maintainer="PostGIS Project - https://postgis.net" \
org.opencontainers.image.description="PostGIS - {{ env.version }} spatial database extension with PostgreSQL {{ .[env.variant].PG_MAJOR }} {{ env.variant }}" \
org.opencontainers.image.source="https://github.com/postgis/docker-postgis"
ARG PGIS1_CMAKE_BUILD_TYPE
ARG PGIS1_BASE_IMAGE
ARG PGIS1_BOOST_VERSION
ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \
PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE} \
PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION}
RUN set -eux \
&& apt-get update \
&& apt-get install -y -V --no-install-recommends \
\
curl \
libboost-atomic${PGIS1_BOOST_VERSION} \
libboost-chrono${PGIS1_BOOST_VERSION} \
libboost-date-time${PGIS1_BOOST_VERSION} \
libboost-filesystem${PGIS1_BOOST_VERSION} \
libboost-program-options${PGIS1_BOOST_VERSION} \
libboost-serialization${PGIS1_BOOST_VERSION} \
libboost-system${PGIS1_BOOST_VERSION} \
libboost-test${PGIS1_BOOST_VERSION} \
libboost-thread${PGIS1_BOOST_VERSION} \
libboost-timer${PGIS1_BOOST_VERSION} \
libcurl3-gnutls \
libexpat1 \
libgmp10 \
libgmpxx4ldbl \
libjson-c5 \
libmpfr6 \
libpcre3 \
libprotobuf-c1 \
{{ if env.variant != "bullseye" then ( -}}
libtiff6 \
{{ ) else ( -}}
libtiff5 \
{{ ) end -}}
libxml2 \
sqlite3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=stage0-builder /_pgis*.* /
COPY --from=stage0-builder /usr/local /usr/local
{{ if .[env.variant].GDAL_BUILD != "minimal" then ( -}}
# Install Arrow + Parquet + other GDAL extra dependencies
RUN set -eux \
# Install Arrow + Parquet
&& apt-get update \
&& apt-get install -y -V ca-certificates wget \
&& wget https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-{{ env.variant }}.deb \
&& apt-get install -y -V ./apache-arrow-apt-source-latest-{{ env.variant }}.deb \
&& apt-get update \
# Load the PGIS1_ARROW version variables
&& . /_pgis1_arrow_environment.env \
# Use the PGIS1_ARROW_SOVERSION as needed
&& echo "Using PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \
&& apt-get install -y -V --no-install-recommends \
libarrow${PGIS1_ARROW_SOVERSION} \
libparquet${PGIS1_ARROW_SOVERSION} \
libarrow-dataset${PGIS1_ARROW_SOVERSION} \
\
# Install GDAL extra dependencies
libblosc1 \
libcrypto++8 \
libfreexl1 \
libfyba0 \
libhdf5-103-1 \
libheif1 \
libkmlbase1 \
libkmldom1 \
libkmlengine1 \
libnetcdf19 \
libopenjp2-7 \
libpng16-16 \
libqhull-r8.0 \
librasterlite2-1 \
libspatialite7 \
netcdf-bin \
{{ if env.variant != "bullseye" then ( -}}
libcfitsio10 \
{{ ) else ( -}}
libcfitsio9 \
{{ ) end -}}
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
{{ ) else ( -}}
# minimal GDAL build; so no need extra dependencies
{{ ) end -}}
ARG PGIS1_GDAL_CHECKOUT
ARG PGIS1_GDAL_REPOSITORY
ARG PGIS1_GEOS_CHECKOUT
ARG PGIS1_GEOS_REPOSITORY
ARG PGIS1_PROJ_CHECKOUT
ARG PGIS1_PROJ_REPOSITORY
ARG PGIS1_SFCGAL_CHECKOUT
ARG PGIS1_SFCGAL_REPOSITORY
ARG PGIS1_CGAL_REPOSITORY
ARG PGIS1_CGAL_CHECKOUT
ARG PGIS1_POSTGIS_CHECKOUT
ARG PGIS1_POSTGIS_REPOSITORY
ARG PGIS1_POSTGIS_CHECKOUT_SHA1
ENV PGIS1_GDAL_CHECKOUT=${PGIS1_GDAL_CHECKOUT} \
PGIS1_GDAL_REPOSITORY=${PGIS1_GDAL_REPOSITORY} \
PGIS1_GEOS_CHECKOUT=${PGIS1_GEOS_CHECKOUT} \
PGIS1_GEOS_REPOSITORY=${PGIS1_GEOS_REPOSITORY} \
PGIS1_PROJ_CHECKOUT=${PGIS1_PROJ_CHECKOUT} \
PGIS1_PROJ_REPOSITORY=${PGIS1_PROJ_REPOSITORY} \
PGIS1_CGAL_CHECKOUT=${PGIS1_CGAL_CHECKOUT} \
PGIS1_CGAL_REPOSITORY=${PGIS1_CGAL_REPOSITORY} \
PGIS1_SFCGAL_CHECKOUT=${PGIS1_SFCGAL_CHECKOUT} \
PGIS1_SFCGAL_REPOSITORY=${PGIS1_SFCGAL_REPOSITORY} \
PGIS1_POSTGIS_CHECKOUT=${PGIS1_POSTGIS_CHECKOUT} \
PGIS1_POSTGIS_REPOSITORY=${PGIS1_POSTGIS_REPOSITORY}
# Minimal command line test ( fail fast )
RUN set -eux \
&& ldconfig \
&& cs2cs \
&& ldd $(which gdalinfo) \
&& gdalinfo --version \
&& gdal-config --formats \
&& geos-config --version \
&& ogr2ogr --version \
&& proj \
&& sfcgal-config --version \
\
# Testing ogr2ogr PostgreSQL driver.
&& ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \
|| echo "ogr2ogr missing PostgreSQL driver" && exit 1
# Specify GDAL_CONFIG and LD_LIBRARY_PATH for PostGIS build;
# The arm64 build is very senitive.
ENV GDAL_CONFIG /usr/local/bin/gdal-config
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
# temporary workaround for : nitdb: invalid locale settings; check LANG and LC_* environment variables
# https://github.com/docker-library/postgres/issues/1112#issuecomment-1746076388
RUN set -eux \
&& echo en_US.UTF-8 UTF-8 >> /etc/locale.gen && locale-gen
RUN set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
autoconf \
automake \
autotools-dev \
bison \
build-essential \
ca-certificates \
cmake \
docbook-xml \
docbook5-xml \
g++ \
git \
libboost-all-dev \
libcunit1-dev \
libcurl4-gnutls-dev \
libgmp-dev \
libjson-c-dev \
libmpfr-dev \
libpcre3-dev \
libprotobuf-c-dev \
libsqlite3-dev \
libtiff-dev \
libtool \
libxml2-dev \
libxml2-utils \
make \
pkg-config \
postgresql-server-dev-$PG_MAJOR \
protobuf-c-compiler \
xsltproc \
&& cd \
# postgis
&& cd /usr/src \
&& mkdir postgis \
&& cd postgis \
&& git init \
&& git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \
&& git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \
&& git checkout FETCH_HEAD \
# Skip SHA1 check if PGIS1_POSTGIS_CHECKOUT_SHA1 is empty or 'nocheck'
# Otherwise, verify that the commit hash matches PGIS1_POSTGIS_CHECKOUT_SHA1
&& if [ -z "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ] \
|| [ "${PGIS1_POSTGIS_CHECKOUT_SHA1}" = "nocheck" ]; then \
echo "Skipping POSTGIS SHA1 check"; \
else \
if [ "$(git rev-parse HEAD)" != "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ]; then \
echo "POSTGIS SHA1 problem! Stop!"; \
exit 1; \
fi; \
fi \
&& git log -1 > /_pgis_last_commit.txt \
&& ldconfig \
&& ./autogen.sh \
# configure options taken from:
# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie
&& ./configure \
--enable-lto \
&& make -j$(nproc) \
&& make install \
# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316
&& if command -v projsync >/dev/null 2>&1; then \
projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \
&& projsync --system-directory --file us_noaa_eshpgn \
&& projsync --system-directory --file us_noaa_prvi \
&& projsync --system-directory --file us_noaa_wmhpgn ; \
fi \
# regress check
&& mkdir /tempdb \
&& chown -R postgres:postgres /tempdb \
&& su postgres -c 'pg_ctl -D /tempdb init' \
&& su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \
&& ldconfig \
&& cd regress \
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \
\
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \
&& 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 'psql -t -c "\dx"' >> /_pgis_full_version.txt \
\
&& su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \
&& rm -rf /tempdb \
&& rm -rf /tmp/logfile \
&& rm -rf /tmp/pgis_reg \
# clean
&& cd / \
&& rm -rf /usr/src/postgis \
&& apt-get purge -y --autoremove \
autoconf \
automake \
autotools-dev \
bison \
build-essential \
cmake \
docbook-xml \
docbook5-xml \
g++ \
git \
libboost-all-dev \
libcurl4-gnutls-dev \
libgmp-dev \
libjson-c-dev \
libmpfr-dev \
libpcre3-dev \
libprotobuf-c-dev \
libsqlite3-dev \
libtiff-dev \
libtool \
libxml2-dev \
libxml2-utils \
make \
pkg-config \
postgresql-server-dev-$PG_MAJOR \
protobuf-c-compiler \
xsltproc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /docker-entrypoint-initdb.d
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
COPY ./update-postgis.sh /usr/local/bin
# last final test
RUN set -eux \
&& ldconfig \
&& cs2cs \
&& ldd $(which gdalinfo) \
&& gdalinfo --version \
&& gdal-config --formats \
&& geos-config --version \
&& ogr2ogr --version \
&& proj \
&& sfcgal-config --version \
# check any missing dependencies
&& ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true \
\
# Is the "ca-certificates" package installed? (for accessing remote raster files)
# https://github.com/postgis/docker-postgis/issues/307
&& dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \
\
# list last commits.
&& find /_pgis*_commit.txt -type f -print -exec cat {} \; \
# list postgresql, postgis version
&& cat _pgis_full_version.txt