Dockerfile_alpine_latest 5.2 KB

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