Skip to content

Commit

Permalink
docker alpine: cleanup and drop Dockerfile_alpine_latest (#2912)
Browse files Browse the repository at this point in the history
- drop `Dockerfile_alpine_latest` as being unsed
- cleanup `Dockerfile`

Co-authored-by:  @tmszi 

(not to be backported)
  • Loading branch information
neteler committed Apr 21, 2023
1 parent ca1bc80 commit a6b672f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 316 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
docker
!docker/testdata
!docker/alpine/grass_tests.sh
.gitignore
.github
.travis
Expand Down
111 changes: 35 additions & 76 deletions docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ LABEL maintainer="neteler@osgeo.org"
ARG PYTHON_VERSION=3

# List of packages to be installed (proj-data omitted: 570.04 MB)
ENV PACKAGES="\
ENV GRASS_RUN_PACKAGES="\
attr \
build-base \
bash \
bison \
bzip2 \
Expand All @@ -19,19 +20,23 @@ ENV PACKAGES="\
fftw \
flex \
freetype \
g++ \
gcc \
gdal \
gdal-dev \
gdal-tools \
gettext \
geos \
geos-dev \
git \
gnutls \
jsoncpp \
laszip \
libbz2 \
libgeotiff \
libjpeg-turbo \
libpng \
libpq-dev \
libunwind \
make \
musl \
Expand All @@ -44,7 +49,7 @@ ENV PACKAGES="\
py3-six \
pdal \
pdal-dev \
postgresql \
postgresql15-client \
proj-util \
sqlite \
sqlite-libs \
Expand All @@ -68,12 +73,11 @@ RUN echo "Install Python";\
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";\
rm -r /root/.cache; \
# Add the packages
echo "Install main packages";\
apk update; \
apk add --no-cache $PACKAGES
apk add --no-cache $GRASS_RUN_PACKAGES


FROM common as build
Expand Down Expand Up @@ -121,17 +125,13 @@ ENV GRASS_BUILD_PACKAGES="\
cairo-dev \
fftw-dev \
freetype-dev \
g++ \
gcc \
gdal-dev \
geos-dev \
git \
gnutls-dev \
libc6-compat \
libjpeg-turbo-dev \
libpng-dev \
libpq-dev \
make \
openjpeg-dev \
openblas-dev \
pdal \
Expand Down Expand Up @@ -178,77 +178,36 @@ RUN cp /usr/local/grass83/gui/wxpython/xml/module_items.xml module_items.xml; \

FROM common as grass

ENV LC_ALL="en_US.UTF-8"

# Copy GRASS GIS from build image
COPY --from=build /usr/local/bin/grass /usr/local/bin/grass
COPY --from=build /usr/local/grass* /usr/local/grass/

# install external Python API
RUN pip3 install --upgrade pip six grass-session --ignore-installed six

RUN ln -sf /usr/local/grass $(grass --config path)
RUN grass --tmp-location XY --exec g.version -rge && \
pdal --version && \
python3 --version


FROM grass as test

## run simple LAZ test
COPY docker/testdata/simple.laz /tmp/simple.laz
COPY docker/testdata/test_grass_session.py /scripts/test_grass_session.py
ENV GRASSBIN=grass

# Test grass-session
# Not yet ready for GRASS GIS 8:
RUN /usr/bin/python3 /scripts/test_grass_session.py
# Test PDAL
RUN grass --tmp-location EPSG:25832 --exec r.in.pdal input="/tmp/simple.laz" output="count_1" method="n" resolution=1 -g

# Test addon installation
RUN apk add --no-cache py3-scikit-learn
RUN grass --tmp-location XY --exec g.extension extension=r.learn.ml2


FROM grass as final

# These packages are required to run g.extension in GRASS GIS.
ENV GRASS_RUN_PACKAGES="\
build-base \
gcc \
libpq-dev \
make \
"

# GRASS GIS specific
# allow work with MAPSETs that are not owned by current user
ENV GRASSBIN="/usr/local/bin/grass" \
GRASS_SKIP_MAPSET_OWNER_CHECK=1 \
SHELL="/bin/bash"

# https://proj.org/usage/environmentvars.html#envvar-PROJ_NETWORK
ENV PROJ_NETWORK=ON

# Add packages for fully enabling g.extension
RUN apk add --no-cache $GRASS_RUN_PACKAGES
SHELL="/bin/bash" \
# https://proj.org/usage/environmentvars.html#envvar-PROJ_NETWORK
PROJ_NETWORK=ON \
GRASSBIN=grass \
LC_ALL="en_US.UTF-8"

# addon test in final stage: does g.extension install also C-extensions?
# test raster C addon
RUN grass --tmp-location XY --exec g.extension extension=r.gwr operation=add
RUN grass --tmp-location XY --exec g.extension extension=r.gwr operation=remove -f
# test vector C addon
RUN grass --tmp-location XY --exec g.extension extension=v.centerpoint operation=add
RUN grass --tmp-location XY --exec g.extension extension=v.centerpoint operation=remove -f

# show installed version
RUN grass --tmp-location XY --exec g.version -rge && \
pdal --version && \
python3 --version
# Copy GRASS GIS from build image
COPY --from=build /usr/local/bin/grass /usr/local/bin/grass
COPY --from=build /usr/local/grass* /usr/local/grass/
# run simple LAZ test
COPY docker/testdata/simple.laz /tmp/
COPY docker/testdata/test_grass_session.py docker/alpine/grass_tests.sh /scripts/
COPY docker/testdata/test_grass_session.py /scripts/

# test r.in.pdal in final image because test stage is not executed in github action
COPY docker/testdata/simple.laz /tmp/simple.laz
RUN grass --tmp-location EPSG:25832 --exec r.in.pdal input="/tmp/simple.laz" output="count_1" method="n" resolution=1 -g
# install external Python API
RUN pip3 install --upgrade pip six grass-session --ignore-installed six; \
ln -sf /usr/local/grass $(grass --config path); \
# run some tests and cleanup
$SHELL /scripts/grass_tests.sh \
&& rm -f /scripts/grass_tests.sh /tmp/simple.laz /scripts/test_grass_session.py; \
# delete unused packages
apk del --no-cache gettext pdal-dev; \
# show installed version
grass --tmp-location XY --exec g.version -rge \
&& pdal --version \
&& python3 --version

# Data workdir
WORKDIR /grassdb
Expand Down

0 comments on commit a6b672f

Please sign in to comment.