-
-
Notifications
You must be signed in to change notification settings - Fork 283
/
Dockerfile_alpine_wxgui
242 lines (215 loc) · 5.75 KB
/
Dockerfile_alpine_wxgui
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
FROM alpine:edge
# Based on:
# https://github.com/mundialis/docker-grass-gis/blob/master/Dockerfile
LABEL authors="Markus Neteler"
LABEL maintainer="neteler@osgeo.org"
# PACKAGES VERSIONS
ARG PYTHON_VERSION=3
# ================
# CONFIG VARIABLES
# ================
# set configuration options, with wxGUI
ENV GRASS_CONFIG="\
--enable-largefile \
--with-cxx \
--with-proj --with-proj-share=/usr/share/proj \
--with-gdal \
--with-python \
--with-geos \
--with-sqlite \
--with-bzlib \
--with-zstd \
--with-cairo --with-cairo-ldflags=-lfontconfig \
--with-fftw \
--with-wxwidgets \
--with-postgres --with-postgres-includes='/usr/include/postgresql' \
--without-freetype \
--without-pdal \
--without-openmp \
--without-opengl \
--without-nls \
--without-mysql \
--without-odbc \
--without-openmp \
--without-ffmpeg \
"
# Set environmental variables for GRASS GIS compilation, without debug symbols
ENV MYCFLAGS="-O2 -std=gnu99 -m64" \
MYLDFLAGS="-s -Wl,--no-undefined -lblas" \
# CXX stuff:
LD_LIBRARY_PATH="/usr/local/lib" \
LDFLAGS="$MYLDFLAGS" \
CFLAGS="$MYCFLAGS" \
CXXFLAGS="$MYCXXFLAGS" \
NUMTHREADS=2
# List of packages to be installed
ENV PACKAGES="\
attr \
bash \
bison \
bzip2 \
cairo \
fftw \
flex \
freetype \
gdal \
gettext \
geos \
gnutls \
gtk+3.0 \
libbz2 \
libjpeg-turbo \
libpng \
musl \
musl-utils \
ncurses \
openjpeg \
openblas \
py3-numpy \
py3-pillow \
py3-six \
postgresql \
proj-datumgrid \
proj-util \
sqlite \
sqlite-libs \
subversion \
tiff \
wxgtk-base \
wxgtk \
zstd \
zstd-libs \
" \
# These packages are required to compile GRASS GIS.
GRASS_BUILD_PACKAGES="\
build-base \
bzip2-dev \
cairo-dev \
fftw-dev \
freetype-dev \
g++ \
gcc \
gdal-dev \
geos-dev \
git \
gnutls-dev \
gtk+3.0-dev \
libc6-compat \
libjpeg-turbo-dev \
libpng-dev \
make \
openjpeg-dev \
openblas-dev \
postgresql-dev \
proj-dev \
python3-dev \
py3-numpy-dev \
sqlite-dev \
tar \
tiff-dev \
unzip \
vim \
wget \
wxgtk-base-dev \
wxgtk-dev \
zip \
zstd-dev \
"
# ====================
# INSTALL DEPENDENCIES
# ====================
WORKDIR /src
ENV PYTHONBIN=python$PYTHON_VERSION
RUN echo "Install Python";\
apk add --no-cache $PYTHONBIN && \
$PYTHONBIN -m ensurepip && \
rm -r /usr/lib/python*/ensurepip && \
pip$PYTHON_VERSION install --upgrade pip setuptools && \
if [ ! -e /usr/bin/pip ]; then ln -s pip$PYTHON_VERSION /usr/bin/pip ; fi && \
if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/$PYTHONBIN /usr/bin/python; fi && \
rm -r /root/.cache
# Add the packages
RUN echo "Install main packages";\
apk update; \
apk add --no-cache \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
$PACKAGES; \
# Add packages just for the GRASS build process
apk add --no-cache \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
--virtual .build-deps $GRASS_BUILD_PACKAGES; \
# echo LANG="en_US.UTF-8" > /etc/default/locale;
#
# compile wxPython, unfortunately there is no Alpine package (yet) - compilation is slow, though!
$PYTHONBIN -m pip install -U pathlib2 wxPython && \
#
# Checkout and install GRASS GIS
#
echo "Install GRASS GIS";\
echo " => Downloading grass"
COPY . /src/grass_build/
# Configure compile and install GRASS GIS
RUN echo " => Configure and compile grass";\
cd /src/grass_build && \
/src/grass_build/configure $GRASS_CONFIG && \
make -j $NUMTHREADS && \
make install && \
ldconfig /etc/ld.so.conf.d; \
#
# enable simple grass command regardless of version number
#
ln -s `find /usr/local/bin -name "grass*"` /usr/local/bin/grass; \
#
# Reduce the image size
#
rm -rf /src/*; \
# remove build dependencies and any leftover apk cache
apk del --no-cache --purge .build-deps; \
rm -rf /var/cache/apk/*; \
rm -rf /root/.cache; \
# Remove unnecessary grass files
rm -rf /usr/local/grass79/demolocation; \
rm -rf /usr/local/grass79/fonts; \
rm -rf /usr/local/grass79/gui; \
rm -rf /usr/local/grass79/share;
# Unset environmental variables to avoid later compilation issues
ENV INTEL="" \
MYCFLAGS="" \
MYLDFLAGS="" \
MYCXXFLAGS="" \
LD_LIBRARY_PATH="" \
LDFLAGS="" \
CFLAGS="" \
CXXFLAGS="" \
# set SHELL var to avoid /bin/sh fallback in interactive GRASS GIS sessions in docker
SHELL="/bin/bash"
# =====================
# INSTALL GRASS-SESSION
# =====================
# install external Python API
RUN pip install grass-session
# set GRASSBIN
ENV GRASSBIN="/usr/local/bin/grass"
# ==================
# TEST grass-session
# ==================
WORKDIR /scripts
COPY docker/testdata/test_grass_session.py .
# TODO: fix test
#RUN /usr/bin/python3 /scripts/test_grass_session.py
# ========
# FINALIZE
# ========
# Data workdir
WORKDIR /grassdb
VOLUME /grassdb
# GRASS GIS specific
# allow work with MAPSETs that are not owned by current user
ENV GRASS_SKIP_MAPSET_OWNER_CHECK=1 \
LC_ALL="en_US.UTF-8"
# show installed version
RUN grass --tmp-location EPSG:4326 --exec g.version -rge && \
python3 --version
CMD [$GRASSBIN, "--version"]