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
  • Loading branch information
neteler committed Jun 4, 2023
1 parent 10d4b93 commit 3290cd6
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 329 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
21 changes: 7 additions & 14 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@

[![Docker Pulls](https://img.shields.io/docker/pulls/mundialis/grass-py3-pdal.svg)](https://grass.osgeo.org/download/software/docker-images/)

<!-- markdownlint-disable line-length -->
| Base image | Docker tag | GRASS GIS | PROJ | GDAL | PDAL | Python | Image size |
|--------------|---------------|------------|-------|-------|-------|--------|------------|
| Ubuntu 22.04 | latest-ubuntu | 8.3.dev | 8.2.1 | 3.4.1 | 2.4.3 | 3.10.6 | 2.89 GB |
| Debian 11 | latest-debian | 8.3.dev | 7.2.1 | 3.2.2 | 2.4.3 | 3.9.2 | 2.93 GB |
| Alpine 3.12 | latest-alpine | 8.3.dev | 7.0.1 | 3.1.4 | 2.1.0 | 3.8.10 | 186 MB |
|--------------|---------------|------------|-------|-------|-------|--------|------------|
| Ubuntu 22.04 | stable-ubuntu | 8.2 branch | 8.2.1 | 3.4.1 | 2.4.3 | 3.10.6 | 2.89 GB |
| Debian 11 | stable-debian | 8.2 branch | 7.2.1 | 3.2.2 | 2.4.3 | 3.9.2 | 2.93 GB |
| Alpine 3.12 | stable-alpine | 8.2 branch | 7.0.1 | 3.1.4 | 2.1.0 | 3.8.10 | 186 MB |
<!-- markdownlint-enable line-length -->

Last update: 22 Jan 2023 (source: <https://github.com/OSGeo/grass/actions/workflows/docker.yml>
and <https://hub.docker.com/r/mundialis/grass-py3-pdal/tags>)
Find out included version of GDAL, GEOS, PROJ, PDAL, Python and GRASS GIS using

```bash
grass --tmp-location XY --exec g.version -rge \
&& pdal --version \
&& python3 --version
```

## Requirements

Expand Down
113 changes: 36 additions & 77 deletions docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.15 as common
FROM alpine:3.18 as common

# Based on:
# https://github.com/mundialis/docker-grass-gis/blob/master/Dockerfile
Expand All @@ -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,20 +20,23 @@ ENV PACKAGES="\
fftw \
flex \
freetype \
g++ \
gcc \
gdal \
gdal-dev \
gdal-tools \
gettext \
geos \
geos-dev \
git \
gnutls \
jsoncpp \
laszip \
libbz2 \
libexecinfo \
libgeotiff \
libjpeg-turbo \
libpng \
libpq-dev \
libunwind \
make \
musl \
Expand All @@ -45,7 +49,7 @@ ENV PACKAGES="\
py3-six \
pdal \
pdal-dev \
postgresql \
postgresql15-client \
proj-util \
sqlite \
sqlite-libs \
Expand All @@ -69,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 @@ -122,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 @@ -179,76 +178,36 @@ RUN cp /usr/local/grass82/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

# 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
SHELL="/bin/bash" \
# https://proj.org/usage/environmentvars.html#envvar-PROJ_NETWORK
PROJ_NETWORK=ON \
GRASSBIN=grass \
LC_ALL="en_US.UTF-8"

# show installed version
RUN grass --tmp-location XY --exec g.version -rge && \
pdal --version && \
python3 --version

# 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
# 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/

# 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 3290cd6

Please sign in to comment.