forked from lithops-cloud/lithops
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.gdal
More file actions
231 lines (204 loc) · 9.24 KB
/
Dockerfile.gdal
File metadata and controls
231 lines (204 loc) · 9.24 KB
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
##
# osgeo/gdal:ubuntu-small
# This file is available at the option of the licensee under:
# Public domain
# or licensed under X/MIT (LICENSE.TXT) Copyright 2019 Even Rouault <even.rouault@spatialys.com>
ARG PROJ_INSTALL_PREFIX=/usr/local
FROM ubuntu:18.04 as builder
# Derived from osgeo/proj by Howard Butler <howard@hobu.co>
MAINTAINER Even Rouault <even.rouault@spatialys.com>
# Setup build env for PROJ
RUN apt-get update -y \
&& apt-get install -y --fix-missing --no-install-recommends \
software-properties-common build-essential ca-certificates \
git make cmake wget unzip libtool automake \
zlib1g-dev libsqlite3-dev pkg-config sqlite3 \
# Newly Added
libhdf4-alt-dev libhdf5-serial-dev libnetcdf-dev
# Setup build env for GDAL
RUN apt-get update -y \
&& apt-get install -y --fix-missing --no-install-recommends \
python3-dev python3-numpy \
libjpeg-dev libgeos-dev \
curl libcurl4-gnutls-dev libexpat-dev libxerces-c-dev \
libwebp-dev \
libzstd1-dev bash zip curl \
libpq-dev libssl-dev \
autoconf automake sqlite3 bash-completion
# Build openjpeg
ARG OPENJPEG_VERSION=2.3.1
RUN if test "${OPENJPEG_VERSION}" != ""; then ( \
wget -q https://github.com/uclouvain/openjpeg/archive/v${OPENJPEG_VERSION}.tar.gz \
&& tar xzf v${OPENJPEG_VERSION}.tar.gz \
&& rm -f v${OPENJPEG_VERSION}.tar.gz \
&& cd openjpeg-${OPENJPEG_VERSION} \
&& cmake . -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
&& make -j$(nproc) \
&& make install \
&& mkdir -p /build_thirdparty/usr/lib \
&& cp -P /usr/lib/libopenjp2*.so* /build_thirdparty/usr/lib \
&& for i in /build_thirdparty/usr/lib/*; do strip -s $i 2>/dev/null || /bin/true; done \
&& cd .. \
&& rm -rf openjpeg-${OPENJPEG_VERSION} \
); fi
ARG PROJ_INSTALL_PREFIX
ARG PROJ_DATUMGRID_LATEST_LAST_MODIFIED
RUN \
mkdir -p /build_projgrids/${PROJ_INSTALL_PREFIX}/share/proj \
&& curl -LOs http://download.osgeo.org/proj/proj-datumgrid-latest.zip \
&& unzip -q -j -u -o proj-datumgrid-latest.zip -d /build_projgrids/${PROJ_INSTALL_PREFIX}/share/proj \
&& rm -f *.zip
RUN apt-get update -y \
&& apt-get install -y --fix-missing --no-install-recommends rsync ccache
ARG RSYNC_REMOTE
# Build PROJ
ARG PROJ_VERSION=master
RUN mkdir proj \
&& wget -q https://github.com/OSGeo/proj.4/archive/${PROJ_VERSION}.tar.gz -O - \
| tar xz -C proj --strip-components=1 \
&& cd proj \
&& ./autogen.sh \
&& if test "${RSYNC_REMOTE}" != ""; then \
echo "Downloading cache..."; \
rsync -ra ${RSYNC_REMOTE}/proj/ $HOME/; \
echo "Finished"; \
export CC="ccache gcc"; \
export CXX="ccache g++"; \
export PROJ_DB_CACHE_DIR="$HOME/.ccache"; \
ccache -M 100M; \
fi \
&& CFLAGS='-DPROJ_RENAME_SYMBOLS -O2' CXXFLAGS='-DPROJ_RENAME_SYMBOLS -O2' \
./configure --prefix=${PROJ_INSTALL_PREFIX} --disable-static \
&& make -j$(nproc) \
&& make install DESTDIR="/build" \
&& if test "${RSYNC_REMOTE}" != ""; then \
ccache -s; \
echo "Uploading cache..."; \
rsync -ra --delete $HOME/.ccache ${RSYNC_REMOTE}/proj/; \
echo "Finished"; \
rm -rf $HOME/.ccache; \
unset CC; \
unset CXX; \
fi \
&& cd .. \
&& rm -rf proj \
&& PROJ_SO=$(readlink /build${PROJ_INSTALL_PREFIX}/lib/libproj.so | sed "s/libproj\.so\.//") \
&& PROJ_SO_FIRST=$(echo $PROJ_SO | awk 'BEGIN {FS="."} {print $1}') \
&& mv /build${PROJ_INSTALL_PREFIX}/lib/libproj.so.${PROJ_SO} /build${PROJ_INSTALL_PREFIX}/lib/libinternalproj.so.${PROJ_SO} \
&& ln -s libinternalproj.so.${PROJ_SO} /build${PROJ_INSTALL_PREFIX}/lib/libinternalproj.so.${PROJ_SO_FIRST} \
&& ln -s libinternalproj.so.${PROJ_SO} /build${PROJ_INSTALL_PREFIX}/lib/libinternalproj.so \
&& rm /build${PROJ_INSTALL_PREFIX}/lib/libproj.* \
&& ln -s libinternalproj.so.${PROJ_SO} /build${PROJ_INSTALL_PREFIX}/lib/libproj.so.${PROJ_SO_FIRST} \
&& strip -s /build${PROJ_INSTALL_PREFIX}/lib/libinternalproj.so.${PROJ_SO} \
&& for i in /build${PROJ_INSTALL_PREFIX}/bin/*; do strip -s $i 2>/dev/null || /bin/true; done
# Build GDAL
ARG GDAL_VERSION=master
ARG GDAL_RELEASE_DATE
ARG GDAL_BUILD_IS_RELEASE
RUN if test "${GDAL_VERSION}" = "master"; then \
export GDAL_VERSION=$(curl -Ls https://api.github.com/repos/OSGeo/gdal/commits/HEAD -H "Accept: application/vnd.github.VERSION.sha"); \
export GDAL_RELEASE_DATE=$(date "+%Y%m%d"); \
fi \
&& if test "x${GDAL_BUILD_IS_RELEASE}" = "x"; then \
export GDAL_SHA1SUM=${GDAL_VERSION}; \
fi \
&& mkdir gdal \
&& wget -q https://github.com/OSGeo/gdal/archive/${GDAL_VERSION}.tar.gz -O - \
| tar xz -C gdal --strip-components=1 \
&& cd gdal/gdal \
&& if test "${RSYNC_REMOTE}" != ""; then \
echo "Downloading cache..."; \
rsync -ra ${RSYNC_REMOTE}/gdal/ $HOME/; \
echo "Finished"; \
# Little trick to avoid issues with Python bindings
printf "#!/bin/sh\nccache gcc \$*" > ccache_gcc.sh; \
chmod +x ccache_gcc.sh; \
printf "#!/bin/sh\nccache g++ \$*" > ccache_g++.sh; \
chmod +x ccache_g++.sh; \
export CC=$PWD/ccache_gcc.sh; \
export CXX=$PWD/ccache_g++.sh; \
ccache -M 1G; \
fi \
&& ./configure --prefix=/usr --without-libtool \
--with-hide-internal-symbols \
--with-jpeg12 \
--with-python \
--with-webp --with-proj=/build${PROJ_INSTALL_PREFIX} \
--with-libtiff=internal --with-rename-internal-libtiff-symbols \
--with-geotiff=internal --with-rename-internal-libgeotiff-symbols \
# Newly Added
--with-hdf5 \
&& make -j$(nproc) \
&& make install DESTDIR="/build" \
&& if test "${RSYNC_REMOTE}" != ""; then \
ccache -s; \
echo "Uploading cache..."; \
rsync -ra --delete $HOME/.ccache ${RSYNC_REMOTE}/gdal/; \
echo "Finished"; \
rm -rf $HOME/.ccache; \
unset CC; \
unset CXX; \
fi \
&& cd ../.. \
&& rm -rf gdal \
&& mkdir -p /build_gdal_python/usr/lib \
&& mkdir -p /build_gdal_python/usr/bin \
&& mkdir -p /build_gdal_version_changing/usr/include \
&& mv /build/usr/lib/python3 /build_gdal_python/usr/lib \
&& mv /build/usr/lib /build_gdal_version_changing/usr \
&& mv /build/usr/include/gdal_version.h /build_gdal_version_changing/usr/include \
&& mv /build/usr/bin/*.py /build_gdal_python/usr/bin \
&& mv /build/usr/bin /build_gdal_version_changing/usr \
&& for i in /build_gdal_version_changing/usr/lib/*; do strip -s $i 2>/dev/null || /bin/true; done \
&& for i in /build_gdal_python/usr/lib/python3/dist-packages/osgeo/*.so; do strip -s $i 2>/dev/null || /bin/true; done \
&& for i in /build_gdal_version_changing/usr/bin/*; do strip -s $i 2>/dev/null || /bin/true; done
# Build final image
FROM ubuntu:18.04 as runner
ENV FLASK_PROXY_PORT 8080
RUN apt-get update \
&& apt-get install -y python3-pip python3-dev \
&& cd /usr/local/bin \
&& ln -s /usr/bin/python3 python \
&& pip3 install --upgrade pip
# PROJ dependencies
RUN apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
libsqlite3-0 \
curl unzip
# GDAL dependencies
RUN apt-get update -y; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3-numpy libpython3.6 \
libjpeg-turbo8 libgeos-3.6.2 libgeos-c1v5 \
libcurl4 libexpat1 \
libxerces-c3.2 \
libwebp6 \
libzstd1 bash libpq5 libssl1.1 \
# Newly Added
libhdf4-0-alt libhdf5-100 libhdf5-cpp-100 libnetcdf-c++4 netcdf-bin
# Order layers starting with less frequently varying ones
COPY --from=builder /build_thirdparty/usr/ /usr/
COPY --from=builder /build_projgrids/usr/ /usr/
ARG PROJ_INSTALL_PREFIX
COPY --from=builder /build${PROJ_INSTALL_PREFIX}/share/proj/ ${PROJ_INSTALL_PREFIX}/share/proj/
COPY --from=builder /build${PROJ_INSTALL_PREFIX}/include/ ${PROJ_INSTALL_PREFIX}/include/
COPY --from=builder /build${PROJ_INSTALL_PREFIX}/bin/ ${PROJ_INSTALL_PREFIX}/bin/
COPY --from=builder /build${PROJ_INSTALL_PREFIX}/lib/ ${PROJ_INSTALL_PREFIX}/lib/
COPY --from=builder /build/usr/share/gdal/ /usr/share/gdal/
COPY --from=builder /build/usr/include/ /usr/include/
COPY --from=builder /build_gdal_python/usr/ /usr/
COPY --from=builder /build_gdal_version_changing/usr/ /usr/
RUN ldconfig
RUN pip install --upgrade pip setuptools six && pip install --no-cache-dir flask gevent ibm-cos-sdk redis pika==0.13.1 requests
# create action working directory
RUN mkdir -p /action
RUN mkdir -p /actionProxy
ADD https://raw.githubusercontent.com/apache/openwhisk-runtime-docker/8b2e205c39d84ed5ede6b1b08cccf314a2b13105/core/actionProxy/actionproxy.py /actionProxy/actionproxy.py
RUN mkdir -p /pythonAction
ADD https://raw.githubusercontent.com/apache/openwhisk-runtime-python/3%401.0.3/core/pythonAction/pythonrunner.py /pythonAction/pythonrunner.py
# Application Layer
# Update numpy version for pyarrow
RUN pip install numpy --upgrade
RUN pip install pyrip pyarrow --upgrade
CMD ["/bin/bash", "-c", "cd /pythonAction && python -u pythonrunner.py"]