FROM osgeo/grass-gis:8.4.0-ubuntu_wxgui AS base
############installing itzi
#https://itzi.readthedocs.io/en/latest/installation.html#installation-on-gnu-linux
RUN mkdir -p ~/miniconda3 \
    && wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh \
    && bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3 \
    && rm -rf ~/miniconda3/miniconda.sh \
    && ~/miniconda3/bin/conda init bash \
    && ls

#COPY --from=base /root/ /root/

RUN echo $PYTHONPATH \
    && export PATH=$PATH:~/miniconda3/bin/ \
    && grass -v \
    && source ~/.bashrc \
    && conda create --name py310venka python=3.10 

RUN source ~/.bashrc \
    && export PATH=$PATH:~/miniconda3/bin/ \
         && conda install -y -c conda-forge pysal rioxarray cartopy setuptools cython six \
         && curl -o /tmp/itzi-20.5.tar.gz \
          https://files.pythonhosted.org/packages/61/e2/de2daf2437ff4006d809a9cf75ad7a55005719539a858712d908d0a540d7/itzi-20.5.tar.gz \
         && cd /tmp \
         && tar -xvf itzi-20.5.tar.gz \
         && cd itzi-20.5 \
         && cython -3 itzi/swmm/swmm_c.pyx itzi/flow.pyx \
         && python setup.py build \
         && python setup.py install

# To build the image from this file:
# sudo docker build . -t itzi:grass_8_4_gui

# To run command from within the container
# sudo docker run -it --rm --volume="$(pwd)/:/data" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --env DISPLAY=$DISPLAY --device="/dev/dri/card0:/dev/dri/card0" itzi:grass_8_4_gui grass --gui

# You can share folders from you local computer with the running Docker container using volumes (-v "$(pwd))

