Dockerfile 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. FROM mundialis/docker-pdal:2.1.0 as pdal
  2. FROM alpine:3.12 as common
  3. # Based on:
  4. # https://github.com/mundialis/docker-grass-gis/blob/master/Dockerfile
  5. LABEL authors="Pietro Zambelli,Markus Neteler"
  6. LABEL maintainer="peter.zamb@gmail.com,neteler@osgeo.org"
  7. # PACKAGES VERSIONS
  8. ARG PYTHON_VERSION=3
  9. # List of packages to be installed
  10. ENV PACKAGES="\
  11. attr \
  12. bash \
  13. bison \
  14. bzip2 \
  15. cairo \
  16. curl \
  17. fftw \
  18. flex \
  19. freetype \
  20. gdal \
  21. gdal-tools \
  22. gettext \
  23. geos \
  24. gnutls \
  25. jsoncpp \
  26. libbz2 \
  27. libexecinfo \
  28. libjpeg-turbo \
  29. libpng \
  30. libunwind \
  31. musl \
  32. musl-utils \
  33. ncurses \
  34. openjpeg \
  35. openblas \
  36. py3-numpy \
  37. py3-pillow \
  38. py3-six \
  39. postgresql \
  40. proj-datumgrid \
  41. proj-util \
  42. sqlite \
  43. sqlite-libs \
  44. subversion \
  45. tiff \
  46. zstd \
  47. zstd-libs \
  48. "
  49. # ====================
  50. # INSTALL DEPENDENCIES
  51. # ====================
  52. WORKDIR /src
  53. ENV PYTHONBIN=python$PYTHON_VERSION
  54. RUN echo "Install Python";\
  55. apk add --no-cache $PYTHONBIN && \
  56. $PYTHONBIN -m ensurepip && \
  57. rm -r /usr/lib/python*/ensurepip && \
  58. pip$PYTHON_VERSION install --upgrade pip setuptools && \
  59. if [ ! -e /usr/bin/pip ]; then ln -s pip$PYTHON_VERSION /usr/bin/pip ; fi && \
  60. if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/$PYTHONBIN /usr/bin/python; fi && \
  61. rm -r /root/.cache
  62. # Add the packages
  63. RUN echo "Install main packages";\
  64. apk update; \
  65. apk add --no-cache $PACKAGES
  66. COPY --from=pdal /usr/bin/pdal* /usr/bin/
  67. COPY --from=pdal /usr/lib/libpdal* /usr/lib/
  68. COPY --from=pdal /usr/lib/pkgconfig/pdal.pc /usr/lib/pkgconfig/pdal.pc
  69. COPY --from=pdal /usr/include/pdal /usr/include/pdal
  70. COPY --from=pdal /usr/local/lib/liblaszip* /usr/local/lib/
  71. COPY --from=pdal /usr/local/include/laszip /usr/local/include/laszip
  72. FROM common as build
  73. # ================
  74. # CONFIG VARIABLES
  75. # ================
  76. # set configuration options, without wxGUI
  77. ENV GRASS_CONFIG="\
  78. --enable-largefile \
  79. --with-cxx \
  80. --with-proj-share=/usr/share/proj \
  81. --with-gdal \
  82. --with-pdal \
  83. --with-geos \
  84. --with-sqlite \
  85. --with-bzlib \
  86. --with-zstd \
  87. --with-cairo --with-cairo-ldflags=-lfontconfig \
  88. --with-fftw \
  89. --with-postgres --with-postgres-includes=/usr/include/postgresql \
  90. --without-freetype \
  91. --without-openmp \
  92. --without-opengl \
  93. --without-nls \
  94. --without-mysql \
  95. --without-odbc \
  96. --without-openmp \
  97. "
  98. # Set environmental variables for GRASS GIS compilation, without debug symbols
  99. ENV MYCFLAGS="-O2 -std=gnu99 -m64" \
  100. MYLDFLAGS="-s -Wl,--no-undefined -lblas" \
  101. # CXX stuff:
  102. LD_LIBRARY_PATH="/usr/local/lib" \
  103. LDFLAGS="$MYLDFLAGS" \
  104. CFLAGS="$MYCFLAGS" \
  105. CXXFLAGS="$MYCXXFLAGS" \
  106. NUMTHREADS=2
  107. # These packages are required to compile GRASS GIS.
  108. ENV GRASS_BUILD_PACKAGES="\
  109. build-base \
  110. bzip2-dev \
  111. cairo-dev \
  112. fftw-dev \
  113. freetype-dev \
  114. g++ \
  115. gcc \
  116. gdal-dev \
  117. geos-dev \
  118. git \
  119. gnutls-dev \
  120. libc6-compat \
  121. libjpeg-turbo-dev \
  122. libpng-dev \
  123. make \
  124. openjpeg-dev \
  125. openblas-dev \
  126. postgresql-dev \
  127. proj-dev \
  128. python3-dev \
  129. py3-numpy-dev \
  130. sqlite-dev \
  131. tar \
  132. tiff-dev \
  133. unzip \
  134. vim \
  135. wget \
  136. zip \
  137. zstd-dev \
  138. "
  139. # Add the packages
  140. RUN echo "Install main packages";\
  141. # Add packages just for the GRASS build process
  142. apk add --no-cache --virtual .build-deps $GRASS_BUILD_PACKAGES
  143. # echo LANG="en_US.UTF-8" > /etc/default/locale;
  144. # Copy and install GRASS GIS
  145. COPY . /src/grass_build/
  146. WORKDIR /src/grass_build/
  147. # Configure compile and install GRASS GIS
  148. RUN echo " => Configure and compile grass" && \
  149. /src/grass_build/configure $GRASS_CONFIG && \
  150. make -j $NUMTHREADS && \
  151. make install && \
  152. ldconfig /etc/ld.so.conf.d
  153. # Reduce the image size - Remove unnecessary grass files
  154. RUN cp /usr/local/grass81/gui/wxpython/xml/module_items.xml module_items.xml; \
  155. rm -rf /usr/local/grass81/demolocation; \
  156. rm -rf /usr/local/grass81/fonts; \
  157. rm -rf /usr/local/grass81/gui; \
  158. rm -rf /usr/local/grass81/share; \
  159. mkdir -p /usr/local/grass81/gui/wxpython/xml/; \
  160. mv module_items.xml /usr/local/grass81/gui/wxpython/xml/module_items.xml;
  161. FROM common as grass
  162. ENV LC_ALL="en_US.UTF-8"
  163. # Copy GRASS GIS from build image
  164. COPY --from=build /usr/local/bin/grass /usr/local/bin/grass
  165. COPY --from=build /usr/local/grass* /usr/local/grass/
  166. # install external Python API
  167. RUN pip3 install --upgrade pip six grass-session --ignore-installed six
  168. RUN ln -sf /usr/local/grass `grass --config path`
  169. RUN grass --tmp-location EPSG:4326 --exec g.version -rge && \
  170. pdal --version && \
  171. python3 --version
  172. FROM grass as test
  173. RUN apk add make gcc
  174. ## run simple LAZ test
  175. COPY docker/testdata/simple.laz /tmp/simple.laz
  176. COPY docker/testdata/test_grass_session.py /scripts/test_grass_session.py
  177. ENV GRASSBIN=grass
  178. RUN grass --tmp-location EPSG:4326 --exec g.extension extension=r.in.pdal
  179. # Not yet ready for GRASS GIS 8:
  180. #RUN /usr/bin/python3 /scripts/test_grass_session.py
  181. RUN grass --tmp-location EPSG:25832 --exec r.in.pdal input="/tmp/simple.laz" output="count_1" method="n" resolution=1 -s
  182. # Test addon installation
  183. RUN grass --tmp-location EPSG:4326 --exec g.extension extension=r.learn.ml
  184. FROM grass as final
  185. # GRASS GIS specific
  186. # allow work with MAPSETs that are not owned by current user
  187. ENV GRASSBIN="/usr/local/bin/grass" \
  188. GRASS_SKIP_MAPSET_OWNER_CHECK=1 \
  189. SHELL="/bin/bash"
  190. # show installed version
  191. RUN grass --tmp-location EPSG:4326 --exec g.version -rge && \
  192. pdal --version && \
  193. python3 --version
  194. # Data workdir
  195. WORKDIR /grassdb
  196. VOLUME /grassdb
  197. CMD $GRASSBIN --version