Skip to content

Commit

Permalink
docker: Alpine latest (stable) added (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
neteler committed Jan 8, 2020
1 parent a070f5e commit 16dc58d
Showing 1 changed file with 237 additions and 0 deletions.
237 changes: 237 additions & 0 deletions docker/alpine/Dockerfile_alpine_latest
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
FROM alpine:latest

# Based on:
# https://github.com/mundialis/docker-grass-gis/blob/master/Dockerfile
LABEL authors="Pietro Zambelli,Markus Neteler"
LABEL maintainer="peter.zamb@gmail.com,neteler@osgeo.org"

# PACKAGES VERSIONS
ARG PYTHON_VERSION=3

# ================
# CONFIG VARIABLES
# ================

# set configuration options, without wxGUI
ENV GRASS_CONFIG="\
--enable-largefile \
--with-cxx \
--with-proj --with-proj-share=/usr/share/proj \
--with-gdal \
--with-pdal \
--with-python \
--with-geos \
--with-sqlite \
--with-bzlib \
--with-zstd \
--with-cairo --with-cairo-ldflags=-lfontconfig \
--with-fftw \
--with-postgres --with-postgres-includes='/usr/include/postgresql' \
--without-freetype \
--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 \
laszip \
libbz2 \
libjpeg-turbo \
libpng \
musl \
musl-utils \
ncurses \
openjpeg \
openblas \
pdal \
py3-numpy \
py3-pillow \
py3-six \
postgresql \
proj-datumgrid \
proj-util \
sqlite \
sqlite-libs \
subversion \
tiff \
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 \
gnutls-dev \
laszip-dev \
libc6-compat \
libjpeg-turbo-dev \
libpng-dev \
make \
openjpeg-dev \
openblas-dev \
pdal-dev \
postgresql-dev \
proj-dev \
python3-dev \
py3-numpy-dev \
sqlite-dev \
tar \
tiff-dev \
unzip \
vim \
wget \
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/latest-stable/main \
$PACKAGES; \
# Add packages just for the GRASS build process
apk add --no-cache \
--repository http://dl-cdn.alpinelinux.org/alpine/latest-stable/main \
--virtual .build-deps $GRASS_BUILD_PACKAGES; \
# echo LANG="en_US.UTF-8" > /etc/default/locale;
#
# 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 and PDAL
# ===========================

WORKDIR /tmp
COPY docker/testdata/simple.laz .
WORKDIR /scripts
COPY docker/testdata/test_grass_session.py .
## just scan the LAZ file
# 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 && \
pdal --version && \
python3 --version

CMD [$GRASSBIN, "--version"]

0 comments on commit 16dc58d

Please sign in to comment.