FROM debian:bullseye

LABEL maintainer="a.ellery@uq.edu.au"

WORKDIR /home

ENV DEBIAN_FRONTEND=noninteractive
ENV OMPI_ALLOW_RUN_AS_ROOT=1
ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
# install packages
RUN echo deb http://deb.debian.org/debian/ buster main non-free contrib >> /etc/apt/sources.list
RUN apt-get -y update
RUN apt-get -y install python3-dev python3-numpy python3-pyproj python3-gdal python3-sympy \
      python3-matplotlib python3-scipy python3-mpi4py \
      libboost-all-dev libnetcdf-dev libnetcdf-cxx-legacy-dev libnetcdf-c++4-dev \
      libmumps-dev libsilo-dev libsuitesparse-dev \
      libopenmpi-dev libcppunit-dev libatlas-base-dev \
      scons git cmake make lsb-release 
# build escript
RUN git clone https://github.com/esys-escript/esys-escript.github.io --depth 1 .
RUN scons options_file=scons/docker_testing.py launcher="mpirun %b" -j`nproc --ignore=1` build_full
ENV LD_LIBRARY_PATH=/home/esys.trilinos/lib:/home/lib:/usr/local/lib:$LD_LIBRARY_PATH
ENV PYTHONPATH=/home:$PYTHONPATH
ENV PATH=/home/bin:$PATH
# run testing
RUN ./utest.sh `pwd`/build '-p2' 

CMD ["/bin/bash"]
