Skip to content

Commit

Permalink
chore(jupyter): update base, non-root install (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
frickjack authored Dec 14, 2020
1 parent dd7a983 commit f4b6f7c
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 48 deletions.
34 changes: 23 additions & 11 deletions jupyter-slim/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
FROM jupyter/scipy-notebook:dd2087c75645
FROM quay.io/cdis/scipy-notebook:5cfa60996e84
USER root

RUN pip install --upgrade nbconvert==5.6.1 && \
pip install --upgrade gen3

## Configure default locale, see https://github.com/rocker-org/rocker/issues/19
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
&& locale-gen en_US.utf8 \
Expand All @@ -23,25 +20,40 @@ RUN apt-get update && \
fonts-texgyre \
gfortran \
gcc \
jq \
make \
automake \
perl \
less \
locales \
libssl1.0.0 \
libssl1.1 \
libssl-dev \
libbz2-dev \
locales \
pkg-config \
tzdata \
vim \
zlib1g \
zlib1g-dev \
libbz2-dev \
libcurl4-gnutls-dev \
liblzma-dev \
openjdk-8-jdk

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

#
# !!!!!NOTE!!!!!
# Do not install conda, python, pip, etc dependencies as root
# It screws up directory permissions
#
USER $NB_UID
WORKDIR /home/$NB_USER


RUN pip install --upgrade nbconvert==5.6.1 && \
pip install --upgrade gen3


#
# R packages including IRKernel which gets installed globally.
# See https://github.com/rocker-org/rocker/blob/master/r-base/Dockerfile
Expand All @@ -56,8 +68,8 @@ RUN wget https://github.com/arq5x/lumpy-sv/releases/download/0.3.0/lumpy-sv.tar.
cd lumpy-sv; make; cp bin/* /usr/local/bin/.; \
rm -rf data/ src/ .git;

USER $NB_UID

COPY resources/custom.js /home/$NB_USER/.jupyter/custom/
COPY resources/jupyter_notebook_config.py /home/$NB_USER/.jupyter/tmp.py
COPY --chown=jovyan:users resources/custom.js /home/$NB_USER/.jupyter/custom/
COPY --chown=jovyan:users resources/jupyter_notebook_config.py /home/$NB_USER/.jupyter/tmp.py
RUN cat /home/$NB_USER/.jupyter/tmp.py >> /home/$NB_USER/.jupyter/jupyter_notebook_config.py && rm /home/$NB_USER/.jupyter/tmp.py

RUN jupyter labextension install jupyterlab-plotly
7 changes: 6 additions & 1 deletion jupyter-slim/resources/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import os

c.NotebookApp.tornado_settings = {
"headers": {"Content-Security-Policy": "frame-ancestors 'self'"}
"headers": {
"Content-Security-Policy": "frame-ancestors self %s"
% os.getenv("FRAME_ANCESTORS", "")
}
}
74 changes: 39 additions & 35 deletions jupyter/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
FROM jupyter/scipy-notebook:3b1f4f5e6cc1
FROM quay.io/cdis/scipy-notebook:5cfa60996e84
USER root

RUN pip install --upgrade nbconvert==5.4.1

#
# R pre-requisites
# https://github.com/rocker-org/rocker/blob/master/r-base/Dockerfile
Expand All @@ -16,32 +14,33 @@ RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \

ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV R_BASE_VERSION 3.6.3

RUN apt-get update && \
apt-get install -y --no-install-recommends \
autoconf \
ca-certificates \
fonts-dejavu \
fonts-texgyre \
gfortran \
gcc \
make \
automake \
perl \
less \
locales \
libssl1.0.0 \
libssl-dev \
tzdata \
vim \
zlib1g \
zlib1g-dev \
libbz2-dev \
libcurl4-gnutls-dev \
liblzma-dev \
openjdk-8-jdk

ENV R_BASE_VERSION 3.6.3
autoconf \
ca-certificates \
fonts-dejavu \
fonts-texgyre \
gfortran \
gcc \
jq \
less \
libssl1.1 \
libssl-dev \
libbz2-dev \
libcurl4-gnutls-dev \
liblzma-dev \
locales \
openjdk-8-jdk \
make \
automake \
perl \
pkg-config \
tzdata \
vim \
zlib1g \
zlib1g-dev

## Now install R and littler, and create a link for littler in /usr/local/bin
#RUN apt-get update \
Expand All @@ -61,6 +60,16 @@ ENV R_BASE_VERSION 3.6.3
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/*

#
# !!!!!NOTE!!!!!
# Do not install conda, python, pip, etc dependencies as root
# It screws up directory permissions
#
USER $NB_UID
WORKDIR /home/$NB_USER

RUN pip install --upgrade nbconvert

#
# R packages including IRKernel which gets installed globally.
# See https://github.com/rocker-org/rocker/blob/master/r-base/Dockerfile
Expand Down Expand Up @@ -92,15 +101,8 @@ RUN conda config --set unsatisfiable_hints True && \
fix-permissions $CONDA_DIR && \
fix-permissions /home/$NB_USER

RUN wget https://github.com/arq5x/lumpy-sv/releases/download/0.3.0/lumpy-sv.tar.gz; \
tar -zxvf lumpy-sv.tar.gz lumpy-sv; rm lumpy-sv.tar.gz; \
cd lumpy-sv; make; cp bin/* /usr/local/bin/.; \
rm -rf data/ src/ .git;

USER $NB_UID

COPY resources/custom.js /home/$NB_USER/.jupyter/custom/
COPY resources/jupyter_notebook_config.py /home/$NB_USER/.jupyter/tmp.py
COPY --chown=jovyan:users resources/custom.js /home/$NB_USER/.jupyter/custom/
COPY --chown=jovyan:users resources/jupyter_notebook_config.py /home/$NB_USER/.jupyter/tmp.py
RUN cat /home/$NB_USER/.jupyter/tmp.py >> /home/$NB_USER/.jupyter/jupyter_notebook_config.py && rm /home/$NB_USER/.jupyter/tmp.py

# This fails ...
Expand All @@ -109,3 +111,5 @@ RUN cat /home/$NB_USER/.jupyter/tmp.py >> /home/$NB_USER/.jupyter/jupyter_notebo
RUN echo "load.lib<-c('httr','jsonlite','dplyr','gplots','ggplot2','ggpubr','RColorBrewer','xml2','repr','VennDiagram'); install.lib<-load.lib[!load.lib %in% installed.packages()]; install.packages(install.lib,dependencies=TRUE, repos='http://cran.us.r-project.org', type='source')" | R --no-save
RUN echo 'if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager",dependencies=TRUE, repos="http://cran.us.r-project.org"); BiocManager::install(ask=FALSE)' | R --no-save
RUN echo "load.s3<-c('maftools', 'phyloseq', 'DESeq2', 'dada2', 'vcfR'); install.s3<-load.s3[!load.s3 %in% installed.packages()]; for(s3 in install.s3) BiocManager::install(s3, ask=FALSE);" | R --no-save

RUN jupyter labextension install jupyterlab-plotly
7 changes: 6 additions & 1 deletion jupyter/resources/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import os

c.NotebookApp.tornado_settings = {
"headers": {"Content-Security-Policy": "frame-ancestors 'self'"}
"headers": {
"Content-Security-Policy": "frame-ancestors self %s"
% os.getenv("FRAME_ANCESTORS", "")
}
}

0 comments on commit f4b6f7c

Please sign in to comment.