FROM jupyter/scipy-notebook:latest

# https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html

# Built from... https://hub.docker.com/r/jupyter/base-notebook/
#               https://github.com/jupyter/docker-stacks/blob/HEAD/base-notebook/Dockerfile
# Built from... Ubuntu 20.04

# The jupyter/docker-stacks images contains jupyterhub and jupyterlab already.

# Example install of git and nbgitpuller.
# NOTE: git is already available in the jupyter/minimal-notebook image.
USER root
RUN apt-get update \
  && apt-get upgrade -y \
  && apt-get install -y --no-install-recommends \
        dnsutils \
        iputils-ping \
  && rm -rf /var/lib/apt/lists/*

# Install language packs
RUN pip install --upgrade pip \
  && pip install jupyterlab-language-pack-zh-CN

# Install Java
# Install dependencies
RUN apt-get update \
  && apt-get install -y \
        software-properties-common \
        curl

# Install Zulu OpenJdk 11 (LTS)
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9 \
  && apt-add-repository 'deb http://repos.azulsystems.com/ubuntu stable main' \
  && apt install -y zulu-11

# Unpack and install the kernel
RUN curl -L https://github.com/SpencerPark/IJava/releases/download/v1.3.0/ijava-1.3.0.zip > ijava-kernel.zip
RUN unzip ijava-kernel.zip -d ijava-kernel \
  && cd ijava-kernel \
  && python3 install.py --sys-prefix

# Install jupyter RISE extension.
RUN pip install --upgrade pip \ 
  && pip install jupyter_contrib-nbextensions RISE \
  && jupyter-nbextension install rise --py --system \
  && jupyter-nbextension enable rise --py --system \
  && jupyter contrib nbextension install --system \
  && jupyter nbextension enable hide_input/main

# Cleanup
RUN rm ijava-kernel.zip \
  && rm -rf ijava-kernel/

# Install C
# Unpack and install the kernel
# RUN curl -L https://github.com/brendan-rius/jupyter-c-kernel/archive/refs/tags/1.2.2.zip > c-kernel.zip
# RUN unzip c-kernel.zip -d c-kernel \
#   && cd c-kernel \
#   && pip install --no-cache-dir c-kernel/ \
#   && install_c_kernel --user

# # Cleanup
# RUN rm c-kernel.zip

RUN git clone https://github.com/brendan-rius/jupyter-c-kernel && cd jupyter-c-kernel
RUN apt-get update \
  && apt-get install -y build-essential \
  && apt-get install -y manpages-dev
RUN pip install --no-cache-dir jupyter-c-kernel/ \
  && install_c_kernel --user
# Cleanup
RUN rm -rf jupyter-c-kernel/

USER $NB_USER

COPY requirements.txt /tmp/requirements.txt
RUN python -m pip install --no-cache-dir \
    -r /tmp/requirements.txt

# Support overriding a package or two through passed docker --build-args.
# ARG PIP_OVERRIDES="jupyterhub==1.3.0"
ARG PIP_OVERRIDES=
RUN if [[ -n "$PIP_OVERRIDES" ]]; then \
        pip install --no-cache-dir $PIP_OVERRIDES; \
    fi

RUN jupyter serverextension enable --py nbgitpuller --sys-prefix

# Uncomment the line below to make nbgitpuller default to start up in JupyterLab
ENV NBGITPULLER_APP=lab

# conda/pip/apt install additional packages here, if desired.
