FROM ubuntu:20.04

ARG NB_USER=jovyan
ARG NB_UID=1000
ENV USER ${NB_USER}
ENV NB_UID ${NB_UID}
ENV HOME /home/${NB_USER}

RUN adduser --disabled-password \
    --gecos "Default user" \
    --uid ${NB_UID} \
    ${NB_USER}
WORKDIR ${HOME}

# Install ubuntu packages
ENV DEBIAN_FRONTEND noninteractive
COPY binder/apt.txt binder/
RUN apt update && cat binder/apt.txt | xargs apt install -y --no-install-recommends && rm -rf /var/lib/apt/lists/*

# Install python packages
COPY binder/requirements.txt binder/

# Install numpy manually first, because of undecleared build dependencies from statsmodels
RUN pip3 install numpy==1.18.1 && pip3 install --no-cache-dir -r binder/requirements.txt

# Copy repository
COPY --chown=${NB_USER}:${NB_USER} . .

USER ${NB_USER}
EXPOSE 8888
CMD jupyter notebook --ip 0.0.0.0
