/
Dockerfile
130 lines (115 loc) · 4.38 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
ARG IMAGE_VERSION
FROM ${IMAGE_VERSION}:build as builder
ENV \
GEOS_VERSION=3.8.1 \
PROJ_VERSION=7.1.1 \
LIBTIFF_VERSION=4.1.0
# libtiff
RUN mkdir /tmp/libtiff \
&& curl -sfL https://download.osgeo.org/libtiff/tiff-${LIBTIFF_VERSION}.tar.gz | tar zxf - -C /tmp/libtiff --strip-components=1 \
&& cd /tmp/libtiff \
&& CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure --prefix=$PREFIX \
&& make -j $(nproc) --silent && make install \
&& rm -rf /tmp/libtiff
# proj
RUN mkdir /tmp/proj && mkdir /tmp/proj/data \
&& curl -sfL http://download.osgeo.org/proj/proj-$PROJ_VERSION.tar.gz | tar zxf - -C /tmp/proj --strip-components=1 \
&& curl -sfL http://download.osgeo.org/proj/proj-datumgrid-latest.tar.gz | tar zxf - -C /tmp/proj/data \
&& cd /tmp/proj \
&& LDFLAGS="-Wl,-rpath,'\$\$ORIGIN'" CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure --prefix=$PREFIX --disable-static --enable-lto \
&& make -j $(nproc) --silent && make install \
&& rm -rf /tmp/proj
# geos
RUN mkdir /tmp/geos \
&& curl -sfL http://download.osgeo.org/geos/geos-$GEOS_VERSION.tar.bz2 | tar jxf - -C /tmp/geos --strip-components=1 \
&& cd /tmp/geos \
&& CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure --prefix=$PREFIX --disable-static \
&& make -j $(nproc) --silent && make install \
&& rm -rf /tmp/geos
ENV PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig/
# gdal
# Use latest commits from Github instead of release
# "release/3.2" is the up to date 3.2.0 github branch
RUN mkdir /tmp/gdal \
&& curl -sfL https://github.com/OSGeo/gdal/archive/release/3.2.tar.gz | tar zxf - -C /tmp/gdal --strip-components=2
RUN cd /tmp/gdal \
&& touch config.rpath \
&& LIBXML2_CFLAGS=$(xml2-config --cflags) LIBXML2_LIBS=$(xml2-config --libs) LDFLAGS="-Wl,-rpath,'\$\$ORIGIN'" CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure \
--disable-debug \
--enable-lto \
--prefix=$PREFIX \
--with-crypto \
--with-curl \
--with-expat \
--with-hdf4=$PREFIX \
--with-hdf5=$PREFIX \
--with-libtiff=$PREFIX \
--with-hide-internal-symbols=yes \
--with-geos=$PREFIX/bin/geos-config \
--with-geotiff=internal \
--with-rename-internal-libgeotiff-symbols \
--with-jpeg=$PREFIX \
--with-rename-internal-libtiff-symbols \
--with-netcdf=$PREFIX \
--with-openjpeg \
--with-pg=yes \
--with-png \
--with-proj=$PREFIX \
--with-sqlite3=$PREFIX \
--with-xml2=yes \
--with-webp=$PREFIX \
--with-zstd=$PREFIX \
--without-cfitsio \
--without-ecw \
--without-fme \
--without-freexl \
--without-jpeg12 \
--without-gif \
--without-gnm \
--without-lerc \
--without-libtool \
--without-pcraster \
--without-pcidsk \
--disable-all-optional-drivers \
--enable-driver-pds \
--enable-driver-shape \
--enable-driver-gpkg \
--enable-driver-sentinel2 \
--enable-driver-xyz \
--enable-driver-flatgeobuf \
--enable-driver-mvt \
--enable-driver-wmts \
--enable-driver-wms \
--enable-driver-mbtiles \
--enable-driver-gpkg \
--enable-driver-gml \
--enable-driver-pgdump
RUN cd /tmp/gdal \
&& make -j $(nproc) --silent && make install \
&& rm -rf /tmp/gdal
# from https://github.com/pypa/manylinux/blob/d8ef5d47433ba771fa4403fd48f352c586e06e43/docker/build_scripts/build.sh#L133-L138
# Install patchelf (latest with unreleased bug fixes)
ENV PATCHELF_VERSION 0.10
RUN mkdir /tmp/patchelf \
&& curl -sfL https://github.com/NixOS/patchelf/archive/$PATCHELF_VERSION.tar.gz | tar zxf - -C /tmp/patchelf --strip-components=1 \
&& cd /tmp/patchelf && ./bootstrap.sh && ./configure \
&& make -j $(nproc) --silent && make install \
&& cd / && rm -rf /tmp/patchelf
# Move /lib64 (libjpeg) to /lib
RUN mv $PREFIX/lib64/lib* $PREFIX/lib/
# FIX
RUN for i in $PREFIX/bin/*; do patchelf --force-rpath --set-rpath '$ORIGIN/../lib' $i; done
# Build final image
FROM lambci/lambda-${IMAGE_VERSION}:build as runner
ENV PREFIX /opt
COPY --from=builder /opt/lib/ $PREFIX/lib/
COPY --from=builder /opt/include/ $PREFIX/include/
COPY --from=builder /opt/share/ $PREFIX/share/
COPY --from=builder /opt/bin/ $PREFIX/bin/
ENV \
GDAL_VERSION=3.2.0 \
GDAL_DATA=$PREFIX/share/gdal \
PROJ_LIB=$PREFIX/share/proj \
GDAL_CONFIG=$PREFIX/bin/gdal-config \
GEOS_CONFIG=$PREFIX/bin/geos-config \
PATH=$PREFIX/bin:$PATH