-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
111 lines (102 loc) · 4.06 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
##
# ***************************************************************************
# begin : April 2019
# author : (C) 2019 by Luigi Pirelli
# author email : luipir at gmail dot com
# copyright : (C) 2019 INSITU
# company web : https://ingenieriainsitu.com/en/
# ***************************************************************************
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License as published by *
# * the Free Software Foundation; either version 2 of the License, or *
# * (at your option) any later version. *
# * *
# ***************************************************************************
##
# ginetto/gdal:2.4.4_ECW
#
# This creates a light Debian derived base image that installs GDAL 2 with ECW extension.
#
# References:
# GDAL compilations steps are inspired by https://github.com/GeographicaGS/Docker-GDAL2
# ECW installation is inspired by: https://gist.github.com/klokan/bfd4a07e8072ffae4bb6
#
FROM debian:stable-slim
LABEL maintainer="Luigi Pirelli <[email protected]>"
# Load assets overrided in docker-compose.yml
ENV ROOTDIR /usr/local/
ARG GDAL_VERSION=2.4.4
ARG ECW_INSTALLER=ERDASECWJP2SDKv54Update1forLinux
ARG ECW_UNZIPPED_INSTALLER=ERDAS_ECWJP2_SDK-5.4.0.bin
ARG ECW_INSTALLED_PATH=ERDAS-ECW_JPEG_2000_SDK-5.4.0
# Install basic dependencies
# on an update system
RUN apt-get update -y && \
apt-get install -y \
software-properties-common \
build-essential \
python-dev \
python3-dev \
python-numpy \
python3-numpy \
libspatialite-dev \
sqlite3 \
libpq-dev \
libcurl4-gnutls-dev \
libproj-dev \
libxml2-dev \
libgeos-dev \
libnetcdf-dev \
libpoppler-dev \
libspatialite-dev \
libhdf4-alt-dev \
libhdf5-serial-dev \
bash-completion \
cmake \
unzip
# maintain the system clean to slim it
RUN apt clean \
&& apt autoclean \
&& apt autoremove
ADD https://go.hexagongeospatial.com/${ECW_INSTALLER} $ROOTDIR/ERDAS_ECW_SDK/
# use this in case already downloaded or hexagon change the way to download
#COPY ./${ECW_INSTALLER} $ROOTDIR/ERDAS_ECW_SDK/
ADD http://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz $ROOTDIR/src/
# Prepare ECW SDK accepting the lincese and installing:
# Desktop_Read-Only (eg. choise 1)
# command MORE=-v is useful to avoid to block installer reading the license.
# see 'more' command documentation.
# printf '1\nyes\n' is useful only to simulate user to select and accept license
RUN cd $ROOTDIR/ERDAS_ECW_SDK/ \
&& unzip ${ECW_INSTALLER} \
&& printf '1\nyes\n' | MORE=-V bash ./${ECW_UNZIPPED_INSTALLER} \
&& mv /hexagon $ROOTDIR
RUN rm -fr $ROOTDIR/ERDAS_ECW_SDK
# configuring ECW SDK to allow gdal compilation
RUN cp -r $ROOTDIR/hexagon/${ECW_INSTALLED_PATH}/Desktop_Read-Only/* $ROOTDIR/hexagon \
&& rm -fr $ROOTDIR/hexagon/${ECW_INSTALLED_PATH}/Desktop_Read-Only \
&& rm -r $ROOTDIR/hexagon/lib/x64 \
&& mv $ROOTDIR/hexagon/lib/newabi/x64 $ROOTDIR/hexagon/lib/x64 \
&& cp $ROOTDIR/hexagon/lib/x64/release/libNCSEcw* $ROOTDIR/lib \
&& ldconfig $ROOTDIR/hexagon
# # Compile and install GDAL
WORKDIR $ROOTDIR/
RUN cd src \
&& tar -xvf gdal-${GDAL_VERSION}.tar.gz \
&& cd gdal-${GDAL_VERSION} \
&& ./configure --with-python --with-spatialite --with-pg --with-curl --with-ecw=/usr/local/hexagon \
&& make -j $(nproc) \
&& make install && ldconfig \
&& apt-get update -y \
&& cd $ROOTDIR \
&& cd src/gdal-${GDAL_VERSION}/swig/python \
&& python3 setup.py build \
&& python3 setup.py install \
&& apt-get remove -y --purge build-essential python-dev python3-dev \
&& cd $ROOTDIR \
&& rm -Rf src/gdal*
# # Output version and capabilities by default.
CMD gdalinfo --version \
&& gdalinfo --formats \
&& ogrinfo --formats