Skip to content

Commit 8e088f7

Browse files
authored
#180 multistage build on master branch (#211)
* #180 multistage build on master branch * WIP: use postgres images for builder, this postgis version may fail in unittest * change builder structures * WIP: use latest master git hash but it fails * bugfix: missing git hash * WIP: set git hash old master but test failed * WIP: enable to build in pg-12 * WIP: use postgis current master * WIP: use gdal current master * use gdal old master, fixes pg-13 * postgis fixes proj issue * #180 update git hash, added comment in top for build, clean up layer
1 parent 45f43c7 commit 8e088f7

File tree

3 files changed

+429
-180
lines changed

3 files changed

+429
-180
lines changed

12-master/Dockerfile

Lines changed: 143 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
FROM postgres:12
1+
# "experimental" ; only for testing!
2+
# multi-stage dockerfile; minimal docker version >= 17.05
3+
FROM postgres:12 as builder
24

35
LABEL maintainer="PostGIS Project - https://postgis.net"
46

5-
ENV SFCGAL_VERSION master
6-
ENV SFCGAL_GIT_HASH 823db7a318b8841f8296e80036ef993ddf19ebf5
7-
ENV PROJ_VERSION master
8-
ENV PROJ_GIT_HASH 9751f31ca9aa42d075421b038f93fe1b1640ffd3
9-
ENV GDAL_VERSION master
10-
ENV GDAL_GIT_HASH 20d44a181f73b87ebb7c1660498bb9e78e572e54
11-
ENV GEOS_VERSION master
12-
ENV GEOS_GIT_HASH 7657bc03d6a587ef02caa689068b130d56ba45e1
13-
ENV POSTGIS_VERSION master
14-
ENV POSTGIS_GIT_HASH 13f821e5906e1a2663eb43b410bb6bd1deba88b6
7+
WORKDIR /
158

9+
# apt-get install
1610
RUN set -ex \
1711
&& apt-get update \
1812
&& apt-get install -y --no-install-recommends \
@@ -38,7 +32,7 @@ RUN set -ex \
3832
libtiff5 \
3933
libxml2 \
4034
sqlite3 \
41-
&& apt-get install -y --no-install-recommends \
35+
# build dependency
4236
autoconf \
4337
automake \
4438
autotools-dev \
@@ -61,70 +55,165 @@ RUN set -ex \
6155
libxml2-dev \
6256
make \
6357
pkg-config \
64-
postgresql-server-dev-$PG_MAJOR \
6558
protobuf-c-compiler \
66-
xsltproc \
67-
# sfcgal
68-
&& mkdir -p /usr/src/sfcgal \
69-
&& cd /usr/src/sfcgal \
70-
&& git init \
71-
&& git remote add origin https://gitlab.com/Oslandia/SFCGAL.git \
72-
&& git fetch --depth 1 origin :${SFCGAL_GIT_HASH} \
73-
&& git reset --hard FETCH_HEAD \
59+
xsltproc
60+
61+
# sfcgal
62+
ENV SFCGAL_VERSION master
63+
ENV SFCGAL_GIT_HASH ea18c06a0f5e6b433e36cad0593c3fe730e5b055
64+
65+
RUN set -ex \
66+
&& mkdir -p /usr/src \
67+
&& cd /usr/src \
68+
&& git clone https://gitlab.com/Oslandia/SFCGAL.git \
69+
&& cd SFCGAL \
70+
&& git checkout ${SFCGAL_GIT_HASH} \
7471
&& mkdir cmake-build \
7572
&& cd cmake-build \
7673
&& cmake .. \
7774
&& make -j$(nproc) \
7875
&& make install \
7976
&& cd / \
80-
&& rm -fr /usr/src/sfcgal \
81-
# proj4
82-
&& mkdir -p /usr/src/proj \
83-
&& cd /usr/src/proj \
84-
&& git init \
85-
&& git remote add origin https://github.com/OSGeo/PROJ.git \
86-
&& git fetch --depth 1 origin :${PROJ_GIT_HASH} \
87-
&& git reset --hard FETCH_HEAD \
77+
&& rm -fr /usr/src/SFCGAL
78+
79+
# proj4
80+
ENV PROJ_VERSION master
81+
ENV PROJ_GIT_HASH d5b0ea29b694a24fb1a951f6fe557f2e1bf78e62
82+
83+
RUN set -ex \
84+
&& cd /usr/src \
85+
&& git clone https://github.com/OSGeo/PROJ.git \
86+
&& cd PROJ \
87+
&& git checkout ${PROJ_GIT_HASH} \
8888
&& ./autogen.sh \
8989
&& ./configure --disable-static \
9090
&& make -j$(nproc) \
9191
&& make install \
9292
&& cd / \
93-
&& rm -fr /usr/src/proj \
94-
# geos
95-
&& mkdir -p /usr/src/geos \
96-
&& cd /usr/src/geos \
97-
&& git init \
98-
&& git remote add origin https://github.com/libgeos/geos.git \
99-
&& git fetch --depth 1 origin :${GEOS_GIT_HASH} \
100-
&& git reset --hard FETCH_HEAD \
93+
&& rm -fr /usr/src/PROJ
94+
95+
# geos
96+
ENV GEOS_VERSION master
97+
ENV GEOS_GIT_HASH 03e8090d9a2019402dbb0d3c2931eac75d11030e
98+
99+
RUN set -ex \
100+
&& cd /usr/src \
101+
&& git clone https://github.com/libgeos/geos.git \
102+
&& cd geos \
103+
&& git checkout ${GEOS_GIT_HASH} \
101104
&& ./autogen.sh \
102105
&& ./configure --disable-static \
103106
&& make -j$(nproc) \
104107
&& make install \
105108
&& cd / \
106-
&& rm -fr /usr/src/geos \
107-
# gdal
108-
&& mkdir -p /usr/src/gdal \
109-
&& cd /usr/src/gdal \
110-
&& git init \
111-
&& git remote add origin https://github.com/OSGeo/gdal.git \
112-
&& git fetch --depth 1 origin :${GDAL_GIT_HASH} \
113-
&& git reset --hard FETCH_HEAD \
109+
&& rm -fr /usr/src/geos
110+
111+
# gdal
112+
ENV GDAL_VERSION master
113+
ENV GDAL_GIT_HASH b08803331acdc351637501e1db8f1e03d2d741f0
114+
115+
RUN set -ex \
116+
&& cd /usr/src \
117+
&& git clone https://github.com/OSGeo/gdal.git \
118+
&& cd gdal \
119+
&& git checkout ${GDAL_GIT_HASH} \
114120
&& cd gdal \
115121
&& ./autogen.sh \
116122
&& ./configure --disable-static \
117123
&& make -j$(nproc) \
118124
&& make install \
119125
&& cd / \
120-
&& rm -fr /usr/src/gdal \
126+
&& rm -fr /usr/src/gdal
127+
128+
# Minimal command line test.
129+
RUN set -ex \
130+
&& ldconfig \
131+
&& cs2cs \
132+
&& gdalinfo --version \
133+
&& geos-config --version \
134+
&& ogr2ogr --version \
135+
&& proj \
136+
&& sfcgal-config --version
137+
138+
FROM postgres:12
139+
140+
RUN set -ex \
141+
&& apt-get update \
142+
&& apt-get install -y --no-install-recommends \
143+
curl \
144+
libboost-atomic1.67.0 \
145+
libboost-chrono1.67.0 \
146+
libboost-date-time1.67.0 \
147+
libboost-filesystem1.67.0 \
148+
libboost-program-options1.67.0 \
149+
libboost-serialization1.67.0 \
150+
libboost-system1.67.0 \
151+
libboost-test1.67.0 \
152+
libboost-thread1.67.0 \
153+
libboost-timer1.67.0 \
154+
libcgal13 \
155+
libcurl3-gnutls \
156+
libexpat1 \
157+
libgmp10 \
158+
libgmpxx4ldbl \
159+
libjson-c3 \
160+
libmpfr6 \
161+
libprotobuf-c1 \
162+
libtiff5 \
163+
libxml2 \
164+
sqlite3 \
165+
&& rm -rf /var/lib/apt/lists/*
166+
167+
COPY --from=builder /usr/local /usr/local
168+
169+
# Minimal command line test.
170+
RUN set -ex \
171+
&& ldconfig \
172+
&& cs2cs \
173+
&& gdalinfo --version \
174+
&& geos-config --version \
175+
&& ogr2ogr --version \
176+
&& proj \
177+
&& sfcgal-config --version
178+
179+
# install postgis
180+
ENV POSTGIS_VERSION master
181+
ENV POSTGIS_GIT_HASH a55328fe58bfec202f12cfa0e831dc3cf5b8e665
182+
183+
RUN set -ex \
184+
&& apt-get update \
185+
&& apt-get install -y --no-install-recommends \
186+
autoconf \
187+
automake \
188+
autotools-dev \
189+
bison \
190+
build-essential \
191+
ca-certificates \
192+
cmake \
193+
git \
194+
g++ \
195+
libboost-all-dev \
196+
libcgal-dev \
197+
libcurl4-gnutls-dev \
198+
libgmp-dev \
199+
libjson-c-dev \
200+
libmpfr-dev \
201+
libprotobuf-c-dev \
202+
libsqlite3-dev \
203+
libtiff-dev \
204+
libtool \
205+
libxml2-dev \
206+
make \
207+
pkg-config \
208+
postgresql-server-dev-$PG_MAJOR \
209+
protobuf-c-compiler \
210+
xsltproc \
211+
&& cd \
121212
# postgis
122-
&& mkdir -p /usr/src/postgis \
123-
&& cd /usr/src/postgis \
124-
&& git init \
125-
&& git remote add origin https://git.osgeo.org/gitea/postgis/postgis.git \
126-
&& git fetch --depth 1 origin :${POSTGIS_GIT_HASH} \
127-
&& git reset --hard FETCH_HEAD \
213+
&& cd /usr/src/ \
214+
&& git clone https://git.osgeo.org/gitea/postgis/postgis.git \
215+
&& cd postgis \
216+
&& git checkout ${POSTGIS_GIT_HASH} \
128217
&& ./autogen.sh \
129218
# configure options taken from:
130219
# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie
@@ -172,14 +261,8 @@ RUN set -ex \
172261
postgresql-server-dev-$PG_MAJOR \
173262
protobuf-c-compiler \
174263
xsltproc \
175-
&& rm -rf /var/lib/apt/lists/* \
176-
# Minimal command line test.
177-
&& cs2cs \
178-
&& gdalinfo --version \
179-
&& geos-config --version \
180-
&& ogr2ogr --version \
181-
&& proj \
182-
&& sfcgal-config --version
264+
&& apt-get clean \
265+
&& rm -rf /var/lib/apt/lists/*
183266

184267
RUN mkdir -p /docker-entrypoint-initdb.d
185268
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh

0 commit comments

Comments
 (0)