Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
feat: Install Julia packages in base image with install.jl file (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgwerner authored Jul 18, 2020
1 parent fc44e93 commit e64e9a4
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 54 deletions.
98 changes: 44 additions & 54 deletions base-notebook/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,71 +1,57 @@
ARG BASE_IMAGE=jupyter/datascience-notebook:76402a27fd13
FROM $BASE_IMAGE

ARG JHUB_HASH_COMMIT=fd28e224f2de5e7b525483330150988ec3e295c6
ARG NBGRADER_VERSION=0.6.1

ENV JHUB_HASH_COMMIT=$JHUB_HASH_COMMIT
ENV DEBIAN_FRONTEND=noninteractive

ENV DEBIAN_FRONTEND=noninteractive
ENV JHUB_CONFIG=$JHUB_CONFIG

USER root

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
apt-transport-https \
curl \
dumb-init \
&& apt-get install -y \
at-spi2-core \
ffmpeg \
gradle \
htop \
libssl-dev \
lsb-release \
maven \
libgl1-mesa-glx \
libgtk-3-dev \
libqt5widgets5 \
libxrender1 \
libxext6 \
libxt6 \
nano \
openjdk-11-jdk \
procps \
ssh \
sudo \
vim \
xauth \
xvfb \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# add nbgrader exchange directory
RUN mkdir -p /srv/nbgrader/exchange \
&& fix-permissions /srv/nbgrader/exchange
USER $NB_UID

# Install packages from requirements file
WORKDIR $HOME

USER $NB_USER

WORKDIR /tmp

# Unpack and install the Java 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
WORKDIR /tmp/ijava-kernel
RUN python3 install.py --sys-prefix \
&& rm ../ijava-kernel.zip
COPY requirements.txt /tmp/jupyternb/requirements.txt
RUN python3 -m pip install --no-cache -r /tmp/jupyternb/requirements.txt

WORKDIR /tmp

# Update JupyterHub version, so that its consistent with version returned
# by JupyterHub API
# Update JupyterHub version, so that its consistent with JupyterHub
RUN git clone https://github.com/jupyterhub/jupyterhub

WORKDIR /tmp/jupyterhub
RUN git checkout -b build $JHUB_HASH_COMMIT \

RUN git checkout -b build fd28e224f2de5e7b525483330150988ec3e295c6 \
&& npm install \
&& npm install tslib \
&& python3 -m pip install .

WORKDIR $HOME
# nbgrader
RUN python3 -m pip install nbgrader=="${NBGRADER_VERSION}" && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"

# copy global nbgrader config
COPY global_nbgrader_config.py /etc/jupyter/nbgrader_config.py

COPY requirements.txt requirements.txt
RUN python3 -m pip install -r requirements.txt \
&& rm requirements.txt \
&& fix-permissions "${CONDA_DIR}" \
&& fix-permissions "/home/${NB_USER}"
# support iframes with jupyter notebooks, copy to local config scope to override
# global notebook configs if they are present
COPY jupyter_notebook_config.py /etc/jupyterhub/jupyter_notebook_config.py

# enable classic notebook extensions
# https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html
Expand All @@ -76,9 +62,17 @@ RUN jupyter contrib nbextension install --sys-prefix && \
# install plotly-orca with npm globally
RUN npm install -g [email protected] orca

# with nbgrader installed, add scripts/configs and update permissions
USER root

RUN mkdir -p /srv/nbgrader/exchange \
&& fix-permissions /srv/nbgrader/exchange

RUN chmod +x /usr/local/bin/start-singleuser.sh

# set container to run with $NB_USER by default
# enable/disable nbgrader extensions
USER $NB_USER
USER $NB_UID

# set up log file location
RUN mkdir -p "/home/${NB_USER}/.local/share/" \
Expand All @@ -93,16 +87,12 @@ RUN jupyter nbextension install --symlink --sys-prefix --py nbgrader --overwrite
&& jupyter serverextension disable --sys-prefix --py nbgrader

# Everybody gets the validate extension, however.
RUN jupyter nbextension enable --sys-prefix validate_assignment/main --section=notebook \
&& jupyter serverextension enable --sys-prefix nbgrader.server_extensions.validate_assignment

# nbgitpuller
RUN jupyter serverextension enable nbgitpuller --sys-prefix
RUN jupyter nbextension enable --sys-prefix validate_assignment/main --section=notebook && \
jupyter serverextension enable --sys-prefix nbgrader.server_extensions.validate_assignment

EXPOSE 8888
WORKDIR /tmp
COPY install.jl /tmp/install.jl
RUN julia install.jl \
&& fix-permissions "${JULIA_PKGDIR}" "${CONDA_DIR}/share/jupyter"

WORKDIR /home/$NB_USER

# copy config files
COPY global_nbgrader_config.py /etc/jupyter/nbgrader_config.py
COPY jupyter_notebook_config.py /etc/jupyterhub/jupyter_notebook_config.py
24 changes: 24 additions & 0 deletions base-notebook/install.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This mechanism allows us to import a package list.
# Source: https://discourse.julialang.org/t/building-a-dockerfile-with-packages/37272/2

using Pkg
pkg"add Colors"
pkg"add CSV"
pkg"add GR"
pkg"add IJulia"
pkg"add ImageView"
pkg"add ImageInTerminal"
pkg"add FileIO"
pkg"add ImageFiltering"
pkg"add Images"
pkg"add ImageFeatures"
pkg"add LinearAlgebra"
pkg"add Plots"
pkg"add PyPlot"
pkg"add Random"
pkg"add GtkReactive"
pkg"add Roots"
pkg"add SymEngine"
pkg"add Statistics"
pkg"add TestImages"
pkg"precompile"
1 change: 1 addition & 0 deletions base-notebook/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

c = get_config()


c.NotebookApp.iopub_data_rate_limit = 1.0e10
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.open_browser = False
Expand Down

0 comments on commit e64e9a4

Please sign in to comment.