#FROM python:3.7-slim
FROM quay.io/fenicsproject/stable:current
USER root

# need git to install from source
# tree allows printing directories in command-line
RUN apt-get update && \
    apt-get install -y \
    tree \
    git \
    ;

# cleaning as we go...
RUN apt-get clean && \
    rm -rf /tmp/*
    
### Install package from source
# bet - dependencies for inverse problem
ENV GIT_ACCOUNT=mathematicalmichael
ENV CLONE_BRANCH=sample
ENV REPO_NAME=bet
RUN cd /tmp && \
    git clone --single-branch --branch ${CLONE_BRANCH} https://github.com/${GIT_ACCOUNT}/${REPO_NAME}.git --depth=1 && \
    cd ${REPO_NAME} && \
    pip install .

# formatting tools for scripts
RUN pip install \
    pyprind  \
    autopep8 \
    black \
    ;

# parallelism
RUN apt-get install -y \
    gfortran \
    libblas-dev \
    liblapack-dev \
    mpich \
    libmpich-dev

RUN apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
    && apt-get autoremove -y

WORKDIR /tmp
# overwrite default python from fenics container
RUN ln -f /usr/bin/python3 /usr/bin/python
RUN ln -f /usr/local/bin/pip3 /usr/local/bin/pip
RUN rm -rf tmp/*
ENTRYPOINT 
CMD ["python3"]
