Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actinia docker image based on GRASS GIS 7.9 (master) #67

Merged
merged 3 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions docker/actinia-core-latest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
FROM mundialis/grass-py3-pdal:latest-ubuntu

# based on GRASS GIS master (grass79)

LABEL authors="Carmen Tawalika,Anika Bettge,Markus Neteler,Sören Gebbert"
LABEL maintainer="[email protected],[email protected],[email protected],[email protected]"

ENV GDAL_CACHEMAX=2000
ENV GRASS_COMPRESSOR=ZSTD

USER root

# Install dependencies and tools
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends --no-install-suggests \
# gnutls-bin \
# libgnutls28-dev \
# ruby \
build-essential \
bzip2 \
curl \
git \
language-pack-en-base \
libcurl4-gnutls-dev \
libpython3-all-dev \
moreutils \
python3 \
python3-dateutil \
python3-dev \
python3-magic \
python3-pip \
python3-ply \
redis-server \
redis-tools \
subversion \
unzip \
vim \
wget \
zip \
&& apt-get autoremove -y \
&& apt-get clean -y

# wrongly linked against gdal 2.2.2; using pygdal 2.2.3.3 in requirements
# python3-gdal \

ENV LC_ALL "en_US.UTF-8"
ENV GRASS_SKIP_MAPSET_OWNER_CHECK 1

# Create the database directories
RUN mkdir -p /actinia_core/grassdb && \
mkdir -p /actinia_core/resources && \
mkdir -p /actinia_core/workspace/tmp && \
mkdir -p /actinia_core/workspace/temp_db && \
mkdir -p /actinia_core/workspace/actinia && \
mkdir -p /actinia_core/workspace/download_cache && \
mkdir -p /actinia_core/userdata

# Create generic GRASS GIS binary name regardless of version number
RUN ln -sf `find /usr/local/bin -name "grass??" | sort | tail -n 1` /usr/local/bin/grass
# Create a generic link to GRASS GIS libs (simplifies actinia configuration)
RUN ln -s `grass --config path` /usr/local/grass7
# show installed version
RUN grass --tmp-location EPSG:4326 --exec g.version -rge

# Install GRASS GIS addons
WORKDIR /src
# Install the d.rast.multi module to render several maps at once
RUN git clone https://[email protected]/huhabla/d_rast_multi.git d.rast.multi
RUN grass --tmp-location EPSG:4326 --exec g.extension -s extension=d.rast.multi url=/src/d.rast.multi

# install some GRASS GIS addons
RUN grass --tmp-location EPSG:4326 --exec g.extension -s extension=i.cutlines && \
grass --tmp-location EPSG:4326 --exec g.extension -s extension=r.colors.out_sld && \
grass --tmp-location EPSG:4326 --exec g.extension -s extension=v.centerpoint

# install SNAPPY
# SNAP wants the current folder '.' included in LD_LIBRARY_PATH
ENV LD_LIBRARY_PATH ".:$LD_LIBRARY_PATH"
RUN apt-get install default-jdk maven -y
ENV JAVA_HOME "/usr/lib/jvm/java-11-openjdk-amd64"
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
COPY docker/actinia-core/snap /src/snap
RUN bash /src/snap/install.sh
RUN update-alternatives --remove python /usr/bin/python3

# Install actinia-core
COPY . /src/actinia_core

# set link to match actinia default config (needed for tests)
RUN ln -s /actinia_core /root/actinia

WORKDIR /src/actinia_core
# necessary to be even with git for clean version
RUN git checkout .
# update build tools
RUN python3 -m pip install --user --upgrade setuptools wheel
# create build
RUN python3 setup.py sdist bdist_wheel

## install (Cython must be installed before requirements.txt)
#RUN pip3 install Cython cython-setuptools setuptools_cython
RUN pip3 install -r requirements.txt && python3 setup.py install
## TODO: fix tests
#\
# && python3 setup.py test

# Install actinia-core plugins
RUN git config --global http.sslVerify false
RUN git clone https://github.com/mundialis/actinia_statistic_plugin.git /src/actinia_statistic_plugin
WORKDIR /src/actinia_statistic_plugin
RUN pip3 install -r requirements.txt && python3 setup.py install
## TODO: fix tests
#\
# && python3 setup.py test

# Reduce the image size
RUN apt-get autoremove -y
RUN apt-get clean -y
RUN rm -rf /src/snap

# Data directory
WORKDIR /grassdb
VOLUME /grassdb

# Copy actinia config file and start scripts
COPY docker/actinia-core/actinia.cfg /etc/default/actinia
COPY docker/actinia-core/start.sh /src/start.sh
COPY docker/actinia-core/start-dev.sh /src/start-dev.sh

ENTRYPOINT ["/bin/bash"]
CMD ["/src/start.sh"]

ENV GISBASE ""

EXPOSE 8088
EXPOSE 9191
35 changes: 35 additions & 0 deletions docker/actinia-core-latest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# actinia docker image

A related docker image created and available for download from here:

https://hub.docker.com/r/mundialis/actinia-core

## Background info

This docker image is based on https://hub.docker.com/r/mundialis/grass-py3-pdal:latest-ubuntu which provides GRASS GIS 7.9 (master, grass79) with Python3 and PDAL support.

The Dockerfile contained in this folder is used to build on Dockerhub.
If you want to build manually...
## mind the build context!

Clone this repository and change directory:

```bash
$ git clone https://github.com/mundialis/actinia_core.git
$ cd actinia_core
```

__Build the docker with__:

```bash
$ docker build \
--file docker/actinia-core-latest/Dockerfile \
--tag actinia-core:latest .
```

View the images available using `sudo docker images` and open a bash terminal with:

```bash
$ docker run -it --entrypoint=/bin/bash actinia-core:latest
root@c5e3b72ad8ba:/grassdb#
```
43 changes: 43 additions & 0 deletions docker/actinia-core-latest/snap/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# https://senbox.atlassian.net/wiki/spaces/SNAP/pages/30539778/Install+SNAP+on+the+command+line
# https://senbox.atlassian.net/wiki/spaces/SNAP/pages/30539785/Update+SNAP+from+the+command+line

# http://step.esa.int/main/download/snap-download/
SNAPVER=7
# avoid NullPointer exception during S-1 processing
java_max_mem=10G

# set JAVA_HOME (done in Docker as well)
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

# install module 'jpy' (A bi-directional Python-Java bridge)
git clone https://github.com/bcdev/jpy.git /src/snap/jpy
pip3 install wheel
(cd /src/snap/jpy && python3 setup.py bdist_wheel)
# hack because ./snappy-conf will create this dir but also needs *.whl files...
mkdir -p /root/.snap/snap-python/snappy
cp /src/snap/jpy/dist/*.whl "/root/.snap/snap-python/snappy"

# install and update snap
wget -q -O /src/snap/esa-snap_all_unix_${SNAPVER}_0.sh \
"http://step.esa.int/downloads/${SNAPVER}.0/installers/esa-snap_all_unix_${SNAPVER}_0.sh"
sh /src/snap/esa-snap_all_unix_${SNAPVER}_0.sh -q -varfile /src/snap/response.varfile
/usr/local/snap/bin/snap --nosplash --nogui --modules --update-all

# create snappy and python binding with snappy
/usr/local/snap/bin/snappy-conf /usr/bin/python3
(cd /root/.snap/snap-python/snappy && python3 setup.py install)

# increase the JAVA VM size to avoid NullPointer exception in Snappy during S-1 processing
(cd /root/.snap/snap-python/snappy && sed -i "s/^java_max_mem:.*/java_max_mem: $java_max_mem/" snappy.ini)

# get minor python version
PYMINOR=$(python3 -c 'import platform; major, minor, patch = platform.python_version_tuple(); print(minor)')
(cd /usr/local/lib/python3.$PYMINOR/dist-packages/snappy/ && sed -i "s/^java_max_mem:.*/java_max_mem: $java_max_mem/" snappy.ini)

# test
/usr/bin/python3 -c 'from snappy import ProductIO'

# cleanup installer
rm -f /src/snap/esa-snap_all_unix_${SNAPVER}_0.sh
14 changes: 14 additions & 0 deletions docker/actinia-core-latest/snap/response.varfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# install4j response file for ESA SNAP 7.0
deleteSnapDir=DESKTOP
executeLauncherWithPythonAction$Boolean=true
forcePython$Boolean=true
pythonExecutable=/usr/bin/python3
sys.adminRights$Boolean=true
sys.component.RSTB$Boolean=true
sys.component.S1TBX$Boolean=true
sys.component.S2TBX$Boolean=true
sys.component.S3TBX$Boolean=true
sys.component.SNAP$Boolean=true
sys.installationDir=/usr/local/snap
sys.languageId=en
sys.programGroupDisabled$Boolean=true
35 changes: 35 additions & 0 deletions docker/actinia-core-latest/start-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# TODO: read paths from config
mkdir -p /actinia_core/grassdb
mkdir -p /actinia_core/userdata
mkdir -p /actinia_core/workspace/temp_db
mkdir -p /actinia_core/workspace/tmp
mkdir -p /actinia_core/resources

# copy pgpass from mounted (!) file
cp /mnt/pgpass/.pgpass $HOME/.pgpass
chmod 0600 $HOME/.pgpass

# copy db.login file from mounted (!) file
cp /mnt/pgpass/.grass7 $HOME/.grass7/dblogin
chmod 0600 $HOME/.grass7/dblogin

# copy db.login file to actinia-core tmp location
mkdir -p /tmp/:/root/.grass7
cp /root/.grass7/dblogin /tmp/:/root/.grass7/

# Create default location in mounted (!) directory
grass -text -e -c 'EPSG:25832' /actinia_core/grassdb/utm32n
grass -text -e -c 'EPSG:4326' /actinia_core/grassdb/latlong_wgs84
# TODO: use this location for tests and integrate sample data, see README
# created here, because set in sample config as default location
grass -text -e -c 'EPSG:3358' /actinia_core/grassdb/nc_spm_08

actinia-user create -u actinia-gdi -w actinia-gdi -r superadmin -g superadmin -c 100000000000 -n 1000 -t 31536000
actinia-user update -u actinia-gdi -w actinia-gdi
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start actinia-user: $status"
exit $status
fi
44 changes: 44 additions & 0 deletions docker/actinia-core-latest/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# TODO: read paths from config
mkdir -p /actinia_core/grassdb
mkdir -p /actinia_core/userdata
mkdir -p /actinia_core/workspace/temp_db
mkdir -p /actinia_core/workspace/tmp
mkdir -p /actinia_core/resources

# copy pgpass from mounted (!) file
cp /mnt/pgpass/.pgpass $HOME/.pgpass
chmod 0600 $HOME/.pgpass

# copy db.login file from mounted (!) file
cp /mnt/pgpass/.grass7 $HOME/.grass7/dblogin
chmod 0600 $HOME/.grass7/dblogin

# copy db.login file to actinia-core tmp location
mkdir -p /tmp/:/root/.grass7
cp /root/.grass7/dblogin /tmp/:/root/.grass7/

# Create default location in mounted (!) directory
grass -text -e -c 'EPSG:25832' /actinia_core/grassdb/utm32n
grass -text -e -c 'EPSG:4326' /actinia_core/grassdb/latlong_wgs84
# TODO: use this location for tests and integrate sample data, see README
# created here, because set in sample config as default location
grass -text -e -c 'EPSG:3358' /actinia_core/grassdb/nc_spm_08

actinia-user create -u actinia-gdi -w actinia-gdi -r superadmin -g superadmin -c 100000000000 -n 1000 -t 31536000
actinia-user update -u actinia-gdi -w actinia-gdi
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start actinia-user: $status"
exit $status
fi

# optimized gunicorn settings (http://docs.gunicorn.org/en/stable/design.html) # run only 1 worker for debugging reasons. This is overwritten for production
# deployment.
gunicorn -b 0.0.0.0:8088 -w 1 --access-logfile=- -k gthread actinia_core.main:flask_app
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start actinia_core/main.py: $status"
exit $status
fi
2 changes: 1 addition & 1 deletion docker/actinia-core-prod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mundialis/actinia-core:latest
FROM mundialis/actinia-core:0.99

# Copy actinia config file and start scripts
COPY actinia.cfg /etc/default/actinia
Expand Down
2 changes: 2 additions & 0 deletions docker/actinia-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM mundialis/grass-py3-pdal:stable-ubuntu

# based on GRASS GIS releasebranch_7_8 (grass78)

LABEL authors="Carmen Tawalika,Anika Bettge,Markus Neteler,Sören Gebbert"
LABEL maintainer="[email protected],[email protected],[email protected],[email protected]"

Expand Down
10 changes: 5 additions & 5 deletions docker/actinia-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ https://hub.docker.com/r/mundialis/actinia-core

## Background info

This docker image is based on https://hub.docker.com/r/mundialis/grass-py3-pdal which provides GRASS GIS 7.8 (release branch, grass78) with python3 and PDAL support.
This docker image is based on https://hub.docker.com/r/mundialis/grass-py3-pdal:stable-ubuntu which provides GRASS GIS 7.8 (release branch, grass78) with Python3 and PDAL support.

The Dockerfile contained in this folder is used to build to dockerhub.
The Dockerfile contained in this folder is used to build on Dockerhub.
If you want to build manually...
## mind the build context!

Expand All @@ -24,13 +24,13 @@ __Build the docker with__:
```bash
$ docker build \
--file docker/actinia-core/Dockerfile \
--tag actinia-core:latest .
--tag actinia-core:stable .
```

View the images available using `sudo docker images` and open a bash terminal with:

```bash
$ docker run -it --entrypoint=/bin/bash actinia-core:latest
$ docker run -it --entrypoint=/bin/bash actinia-core:stable
root@c5e3b72ad8ba:/grassdb#
```

Expand All @@ -48,6 +48,6 @@ $ docker build \
--file docker/actinia-core/Dockerfile \
--tag actinia-core:stable .

$ docker run -it --entrypoint=/bin/bash actinia-core:latest
$ docker run -it --entrypoint=/bin/bash actinia-core:stable
root@c5e3b72ad8ba:/grassdb#
```