-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatest.Dockerfile
252 lines (227 loc) · 8 KB
/
latest.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
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
ARG BASE_IMAGE=debian
ARG BASE_IMAGE_TAG=12
ARG BUILD_ON_IMAGE=glcr.b-data.ch/jupyterlab/r/geospatial
ARG R_VERSION
ARG QGIS_VERSION
ARG SAGA_VERSION
ARG OTB_VERSION
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG} as files
ARG OTB_VERSION
ARG NB_UID=1000
ENV NB_GID=100
RUN mkdir /files
COPY conf/user /files
COPY scripts /files
RUN if [ "$(uname -m)" = "x86_64" ]; then \
## QGIS: Set OTB application folder and OTB folder
qgis3Ini="/files/var/backups/skel/.local/share/QGIS/QGIS3/profiles/default/QGIS/QGIS3.ini"; \
echo "\n[Processing]" >> ${qgis3Ini}; \
if [ -z "${OTB_VERSION}" ]; then \
echo "Configuration\OTB_APP_FOLDER=/usr/lib/otb/applications" >> \
${qgis3Ini}; \
echo "Configuration\OTB_FOLDER=/usr\n" >> ${qgis3Ini}; \
else \
echo "Configuration\OTB_APP_FOLDER=/usr/local/lib/otb/applications" >> \
${qgis3Ini}; \
echo "Configuration\OTB_FOLDER=/usr/local\n" >> ${qgis3Ini}; \
fi \
fi \
&& chown -R ${NB_UID}:${NB_GID} /files/var/backups/skel \
## Ensure file modes are correct when using CI
## Otherwise set to 777 in the target image
&& find /files -type d -exec chmod 755 {} \; \
&& find /files -type f -exec chmod 644 {} \; \
&& find /files/usr/local/bin -type f -exec chmod 755 {} \;
FROM glcr.b-data.ch/qgis/qgissi/${QGIS_VERSION}/${BASE_IMAGE}:${BASE_IMAGE_TAG} as qgissi
FROM glcr.b-data.ch/saga-gis/saga-gissi${SAGA_VERSION:+/}${SAGA_VERSION:-:none}${SAGA_VERSION:+/$BASE_IMAGE}${SAGA_VERSION:+:$BASE_IMAGE_TAG} as saga-gissi
FROM glcr.b-data.ch/orfeotoolbox/otbsi${OTB_VERSION:+/}${OTB_VERSION:-:none}${OTB_VERSION:+/$BASE_IMAGE}${OTB_VERSION:+:$BASE_IMAGE_TAG} as otbsi
FROM ${BUILD_ON_IMAGE}:${R_VERSION}
ARG NCPUS=1
ARG DEBIAN_FRONTEND=noninteractive
ARG BUILD_ON_IMAGE
ARG QGIS_VERSION
ARG SAGA_VERSION
ARG OTB_VERSION
ARG BUILD_START
ENV PARENT_IMAGE=${BUILD_ON_IMAGE}:${R_VERSION} \
QGIS_VERSION=${QGIS_VERSION} \
SAGA_VERSION=${SAGA_VERSION} \
OTB_VERSION=${OTB_VERSION} \
BUILD_DATE=${BUILD_START}
USER root
ENV HOME=/root \
## GRASS GIS: Make sure the distro's python is used
GRASS_PYTHON=/usr/bin/python3
WORKDIR ${HOME}
## Install QGIS
COPY --from=qgissi /usr /usr
## Install SAGA GIS
COPY --from=saga-gissi /usr/local /usr/local
## Install Orfeo Toolbox
COPY --from=otbsi /usr/local /usr/local
ENV GDAL_DRIVER_PATH=${OTB_VERSION:+disable} \
OTB_APPLICATION_PATH=${OTB_VERSION:+/usr/local/lib/otb/applications}
ENV OTB_APPLICATION_PATH=${OTB_APPLICATION_PATH:-/usr/lib/otb/applications}
RUN apt-get update \
&& apt-get -y install --no-install-recommends \
## QGIS: Additional runtime dependencies
'^libexiv2-[0-9]+$' \
'^libgdal[0-9]+$' \
libgeos-c1v5 \
'^libgsl[0-9]+$' \
libjs-jquery \
libjs-leaflet \
'^libprotobuf-lite[0-9]+$' \
libqca-qt5-2-plugins \
'^libqscintilla2-qt5-[0-9]+$' \
libqt5core5a \
libqt5gui5 \
libqt5keychain1 \
libqt5multimediawidgets5 \
libqt5network5 \
libqt5quickwidgets5 \
libqt5serialport5 \
libqt5sql5 \
libqt5webkit5 \
libqt5widgets5 \
libqt5xml5 \
libqwt-qt5-6 \
'^libspatialindex[0-9]+$' \
'^libzip[0-9]+$' \
ocl-icd-libopencl1 \
qt3d-assimpsceneimport-plugin \
qt3d-defaultgeometryloader-plugin \
qt3d-gltfsceneio-plugin \
qt3d-scene2d-plugin \
qt5-image-formats-plugins \
## QGIS: Python 3 Support
gdal-bin \
libfcgi0ldbl \
libsqlite3-mod-spatialite \
python3-gdal \
python3-jinja2 \
python3-lxml \
python3-matplotlib \
python3-owslib \
python3-plotly \
python3-psycopg2 \
python3-pygments \
python3-pyproj \
python3-pyqt5 \
python3-pyqt5.qsci \
python3-pyqt5.qtmultimedia \
python3-pyqt5.qtpositioning \
python3-pyqt5.qtsql \
python3-pyqt5.qtsvg \
python3-pyqt5.qtwebkit \
python3-sip \
python3-yaml \
qttools5-dev-tools \
## QGIS: Additional runtime recommendations
grass \
## QGIS: Additional runtime suggestions
gpsbabel \
## SAGA GIS: Supplementary runtime dependencies [^1]
libdxflib3 \
libhpdf-2.3.0 \
libsvm3 \
libwxgtk3.*-dev \
$(test -z "${SAGA_VERSION}" && echo "saga") \
## Orfeo Toolbox: Supplementary runtime dependencies
&& if [ "$(uname -m)" = "x86_64" ]; then \
apt-get -y install --no-install-recommends \
'^libboost-filesystem[0-9].[0-9]+.[0-9]$' \
'^libboost-serialization[0-9].[0-9]+.[0-9]$' \
libglew2.* \
'^libinsighttoolkit4.[0-9]+$' \
libmuparser2v5 \
libmuparserx4.* \
'^libopencv-core[0-9][0-9.][0-9][a-z]?$' \
'^libopencv-ml[0-9][0-9.][0-9][a-z]?$' \
libtinyxml-dev \
$(test -z "${OTB_VERSION}" && echo "otb-* monteverdi"); \
if [ ! -z "${OTB_VERSION}" ]; then \
if [ "$(echo ${OTB_VERSION} | cut -c 1)" -lt "8" ]; then \
apt-get -y install --no-install-recommends \
'^libopenthreads[0-9]+$' \
libossim1; \
fi \
else \
mkdir -p /usr/lib/otb; \
ln -rs /usr/lib/$(uname -m)-linux-gnu/otb/applications \
/usr/lib/otb/applications; \
fi \
fi \
## GRASS GIS: Configure dynamic linker run time bindings
&& echo "$(grass --config path)/lib" | tee /etc/ld.so.conf.d/libgrass.conf \
&& ldconfig \
## SAGA GIS: Add en_GB.UTF-8 and update locale
&& sed -i "s/# $LANG/$LANG/g" /etc/locale.gen \
&& sed -i "s/# en_GB.UTF-8/en_GB.UTF-8/g" /etc/locale.gen \
&& locale-gen \
## [^1]: SAGA GIS: libvigraimpex11 is not available for jammy
&& if $(! grep -q "jammy" /etc/os-release); then \
apt-get -y install --no-install-recommends '^libvigraimpex[0-9]+$'; \
fi \
## Clean up
&& rm -rf /tmp/* \
&& rm -rf /var/lib/apt/lists/* \
${HOME}/.cache \
${HOME}/.grass*
## Install QGIS related stuff
RUN apt-get update \
## Install QGIS-Plugin-Manager
&& apt-get -y install --no-install-recommends python3-pip \
&& export PIP_BREAK_SYSTEM_PACKAGES=1 \
&& /usr/bin/pip install qgis-plugin-manager \
## QGIS: Make sure qgis_mapserver and qgis_process find the qgis module
&& cp -a $(which qgis_mapserver) $(which qgis_mapserver)_ \
&& echo '#!/bin/bash' > $(which qgis_mapserver) \
&& echo "PYTHONPATH=/usr/lib/python3/dist-packages $(which qgis_mapserver)_ \"\${@}\"" >> \
$(which qgis_mapserver) \
&& cp -a $(which qgis_process) $(which qgis_process)_ \
&& echo '#!/bin/bash' > $(which qgis_process) \
&& echo "PYTHONPATH=/usr/lib/python3/dist-packages $(which qgis_process)_ \"\${@}\"" >> \
$(which qgis_process) \
## Install qgisprocess, the R interface to QGIS
&& R -e "devtools::install_github('r-spatial/qgisprocess')" \
## Clean up
&& if [ ! -z "$PYTHON_VERSION" ]; then \
apt-get -y purge python3-pip; \
apt-get -y autoremove; \
fi \
&& rm -rf /var/lib/apt/lists/* \
${HOME}/.cache \
${HOME}/.config \
${HOME}/.local
## Switch back to ${NB_USER} to avoid accidental container runs as root
USER ${NB_USER}
ENV HOME=/home/${NB_USER} \
## Qt: Support running on headless computer
QT_QPA_PLATFORM=offscreen
WORKDIR ${HOME}
## Copy files as late as possible to avoid cache busting
COPY --from=files /files /
COPY --from=files /files/var/backups/skel ${HOME}
## QGIS: Install plugin 'Processing Saga NextGen Provider'
RUN mkdir -p ${HOME}/.local/share/QGIS/QGIS3/profiles/default/python/plugins \
&& cd ${HOME}/.local/share/QGIS/QGIS3/profiles/default/python/plugins \
&& qgis-plugin-manager init \
&& qgis-plugin-manager update \
&& qgis-plugin-manager install 'Processing Saga NextGen Provider' \
&& rm -rf .cache_qgis_plugin_manager \
## QGIS: Enable plugins
&& qgis_process plugins enable processing_saga_nextgen \
&& qgis_process plugins enable grassprovider \
&& if [ "$(uname -m)" = "x86_64" ]; then \
## QGIS: Enable OTB plugin
qgis_process plugins enable otbprovider; \
fi \
## Clean up
&& rm -rf \
${HOME}/.cache \
${HOME}/.config \
${HOME}/.grass* \
## Create backup of QGIS settings
&& cp -a ${HOME}/.local/share/QGIS /var/backups/skel/.local/share
ENV PYTHONPATH=${PYTHONPATH:+$PYTHONPATH:}${OTB_VERSION:+/usr/local/lib/otb/python}