-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding a bioconductor base (#67)
- Loading branch information
Showing
8 changed files
with
297 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
ARG RELEASE=RELEASE_3_10 | ||
FROM bioconductor/bioconductor_docker:${RELEASE} | ||
LABEL maintainer="Swiss Data Science Center <[email protected]>" | ||
|
||
USER root | ||
|
||
ENV NB_USER rstudio | ||
ENV NB_UID 1000 | ||
ENV NB_GID 1000 | ||
ENV VENV_DIR /srv/venv | ||
ENV HOME /home/${NB_USER} | ||
ENV SHELL bash | ||
ENV CONDA_PATH /opt/conda | ||
|
||
# prepend conda to PATH | ||
ENV PATH ${CONDA_PATH}/bin:$PATH | ||
# And set PATH for R! It doesn't read from the environment... | ||
RUN echo "PATH=${PATH}" >> /usr/local/lib/R/etc/Renviron && \ | ||
echo "PATH=${PATH}" >> /etc/profile.d/set_path.sh | ||
|
||
# The `rsession` binary that is called by nbrsessionproxy to start R doesn't seem to start | ||
# without this being explicitly set | ||
ENV LD_LIBRARY_PATH /usr/local/lib/R/lib | ||
|
||
# Add Tini | ||
ENV TINI_VERSION v0.18.0 | ||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini | ||
RUN chmod +x /tini | ||
|
||
# install miniconda (https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/debian/Dockerfile) | ||
RUN apt-get update --fix-missing && \ | ||
apt-get install -yq --no-install-recommends \ | ||
bzip2 \ | ||
ca-certificates \ | ||
curl \ | ||
gnupg \ | ||
libglib2.0-0 \ | ||
libsm6 \ | ||
libxext6 \ | ||
libxrender1 \ | ||
wget \ | ||
vim && \ | ||
apt-get purge && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# install git-lfs | ||
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && \ | ||
apt-get install git-lfs | ||
|
||
WORKDIR /tmp | ||
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.6.14-Linux-x86_64.sh -O ~/miniconda.sh && \ | ||
/bin/bash ~/miniconda.sh -b -p ${CONDA_PATH} && \ | ||
rm ~/miniconda.sh && \ | ||
${CONDA_PATH}/bin/conda clean -tipsy && \ | ||
ln -s ${CONDA_PATH}/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ | ||
${CONDA_PATH}/bin/conda config --system --append channels conda-forge && \ | ||
${CONDA_PATH}/bin/conda config --system --set auto_update_conda false && \ | ||
find ${CONDA_PATH}/ -follow -type f -name '*.a' -delete && \ | ||
find ${CONDA_PATH}/ -follow -type f -name '*.js.map' -delete && \ | ||
${CONDA_PATH}/bin/conda clean -afy | ||
|
||
# set permissions in the conda directory to be editable by NB_USER | ||
ADD fix-permissions.sh /usr/local/bin | ||
RUN fix-permissions.sh ${CONDA_PATH} | ||
|
||
USER ${NB_USER} | ||
|
||
# set up conda in the NB_USER environment | ||
RUN echo ". ${CONDA_PATH}/etc/profile.d/conda.sh" >> ~/.bashrc && \ | ||
echo "conda activate base" >> ~/.bashrc | ||
|
||
# install the jupyter stack | ||
ARG JUPYTERHUB_VERSION=0.9.6 | ||
|
||
RUN ${CONDA_PATH}/bin/conda install --quiet --yes \ | ||
'notebook=6.0.0' \ | ||
"jupyterhub=${JUPYTERHUB_VERSION}" \ | ||
'jupyterlab=1.2.1' && \ | ||
${CONDA_PATH}/bin/conda install -c conda-forge 'nodejs>=6.11.5' && \ | ||
${CONDA_PATH}/bin/conda install --quiet --yes conda-build && \ | ||
${CONDA_PATH}/bin/conda build purge-all && \ | ||
npm cache clean --force | ||
|
||
RUN jupyter notebook --generate-config && \ | ||
rm -rf ${CONDA_PATH}/share/jupyter/lab/staging && \ | ||
rm -rf /home/$NB_USER/.cache/yarn && \ | ||
pip install -U --no-cache-dir pip wheel | ||
|
||
|
||
# install jupyterlab, git extension | ||
RUN python3 -m pip install -U pip && \ | ||
jupyter labextension update @jupyterlab/hub-extension --no-build && \ | ||
jupyter labextension install @jupyterlab/git --no-build && \ | ||
jupyter labextension list && \ | ||
pip install jupyter-rsession-proxy && \ | ||
pip install jupyterlab-git && \ | ||
jupyter serverextension enable --py jupyterlab_git && \ | ||
jupyter lab build | ||
|
||
# install IRKernel | ||
RUN R --quiet -e "install.packages('IRkernel')" && \ | ||
R --quiet -e "IRkernel::installspec(prefix='${CONDA_PATH}')" | ||
|
||
# install renku | ||
# the RENKU_PIP_SPEC should be e.g. "renku==0.5.2" | ||
ARG RENKU_PIP_SPEC="renku" | ||
RUN python3 -m pip install pipx>=0.15.0.0 && \ | ||
pipx install ${RENKU_PIP_SPEC} --pip-args="--pre" && \ | ||
pipx inject renku sentry-sdk && \ | ||
pipx ensurepath | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT [ "/tini", "--", "/entrypoint.sh" ] | ||
CMD [ "jupyterhub-singleuser" ] | ||
|
||
WORKDIR ${HOME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Licensing terms | ||
|
||
`fix-permissions.sh` is licensed under the terms of the Modified BSD License | ||
(also known as New or Revised or 3-Clause BSD), as follows: | ||
|
||
- Copyright (c) 2001-2015, IPython Development Team | ||
- Copyright (c) 2015-, Jupyter Development Team | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
Redistributions in binary form must reproduce the above copyright notice, this | ||
list of conditions and the following disclaimer in the documentation and/or | ||
other materials provided with the distribution. | ||
|
||
Neither the name of the Jupyter Development Team nor the names of its | ||
contributors may be used to endorse or promote products derived from this | ||
software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
## About the Jupyter Development Team | ||
|
||
The Jupyter Development Team is the set of all contributors to the Jupyter project. | ||
This includes all of the Jupyter subprojects. | ||
|
||
The core team that coordinates development on GitHub can be found here: | ||
https://github.com/jupyter/. | ||
|
||
## Our Copyright Policy | ||
|
||
Jupyter uses a shared copyright model. Each contributor maintains copyright | ||
over their contributions to Jupyter. But, it is important to note that these | ||
contributions are typically only changes to the repositories. Thus, the Jupyter | ||
source code, in its entirety is not the copyright of any single person or | ||
institution. Instead, it is the collective copyright of the entire Jupyter | ||
Development Team. If individual contributors want to maintain a record of what | ||
changes/contributions they have specific copyright on, they should indicate | ||
their copyright in the commit message of the change, when they commit the | ||
change to one of the Jupyter repositories. | ||
|
||
With this in mind, the following banner should be used in any source code file | ||
to indicate the copyright and license terms: | ||
|
||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
# Copy the relevant system environment variables to the R-specific locations | ||
VariableArray=("GIT_COMMITTER_NAME" "GIT_AUTHOR_NAME" "EMAIL") | ||
for var in ${VariableArray[*]}; do | ||
if [ -n "${!var}" ]; then | ||
echo $var=${!var} >> ${HOME}/.Renviron | ||
fi | ||
done | ||
|
||
# Setup git user | ||
if [ -z "$(git config --global --get user.name)" ]; then | ||
git config --global user.name "$GIT_AUTHOR_NAME" | ||
fi | ||
if [ -z "$(git config --global --get user.email)" ]; then | ||
git config --global user.email "$EMAIL" | ||
fi | ||
|
||
# add a symlink to the project directory in /home/rstudio | ||
[ -n "$CI_PROJECT" ] && ln -s /work/${CI_PROJECT} /home/rstudio | ||
|
||
# configure rstudio to open the rpath project | ||
if [[ ! -f /home/rstudio/${CI_PROJECT}/${CI_PROJECT}.Rproj ]]; then | ||
cat > /home/rstudio/${CI_PROJECT}/${CI_PROJECT}.Rproj <<- EOM | ||
Version: 1.0 | ||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
EOM | ||
fi | ||
mkdir -p /home/rstudio/.rstudio/projects_settings | ||
echo /home/rstudio/${CI_PROJECT}/${CI_PROJECT}.Rproj | tee /home/rstudio/.rstudio/projects_settings/next-session-project | ||
chown -R rstudio:root /home/rstudio/.rstudio/projects_settings | ||
|
||
# | ||
# copy the environment from renku-env repo | ||
# | ||
|
||
# clone the repo | ||
proto=$(echo $GITLAB_URL | sed -e's,^\(.*://\).*,\1,g') | ||
url=$(echo ${GITLAB_URL/$proto/}) | ||
user=$(echo ${CI_REPOSITORY_URL/$proto/} | grep @ | cut -d@ -f1) | ||
|
||
git clone --depth 1 ${proto}${user}@${url}/${JUPYTERHUB_USER}/renku-env.git /tmp/renku-env || true | ||
|
||
# append the contents of all the files to same files in ${HOME} | ||
find /tmp/renku-env -not -path '*.git*' -type f -print0 | xargs --null -I{} sh -c 'cat {} >> ${HOME}/$(basename "{}")' || true | ||
|
||
# run the command | ||
$@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
# set permissions on a directory | ||
# after any installation, if a directory needs to be (human) user-writable, | ||
# run this script on it. | ||
# It will make everything in the directory owned by the group $NB_GID | ||
# and writable by that group. | ||
# Deployments that want to set a specific user id can preserve permissions | ||
# by adding the `--group-add users` line to `docker run`. | ||
|
||
# uses find to avoid touching files that already have the right permissions, | ||
# which would cause massive image explosion | ||
|
||
# right permissions are: | ||
# group=$NB_GID | ||
# AND permissions include group rwX (directory-execute) | ||
# AND directories have setuid,setgid bits set | ||
|
||
set -e | ||
|
||
for d in "$@"; do | ||
find "$d" \ | ||
! \( \ | ||
-group $NB_GID \ | ||
-a -perm -g+rwX \ | ||
\) \ | ||
-exec chgrp $NB_GID {} \; \ | ||
-exec chmod g+rwX {} \; | ||
# setuid,setgid *on directories only* | ||
find "$d" \ | ||
\( \ | ||
-type d \ | ||
-a ! -perm -6000 \ | ||
\) \ | ||
-exec chmod +6000 {} \; | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters