Skip to content

Commit

Permalink
feat: add julia (#84)
Browse files Browse the repository at this point in the history
Co-authored-by: Emma Jablonski <[email protected]>
  • Loading branch information
rokroskar and emmjab authored Apr 3, 2020
1 parent 4d0b748 commit 031fa69
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 4 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/build_and_push_to_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ jobs:
strategy:
fail-fast: true
matrix:
RENKU_VERSION: ["", "0.9.1", "0.10.2"]
EXTENSIONS: ["py3.7", "r3.6.1", "bioc3_10", "cuda9.2", "cuda10.0-tf1.14"]

RENKU_VERSION:
- ""
- "0.9.1"
- "0.10.2"
EXTENSIONS:
- py3.7
- r3.6.1
- bioc3_10
- cuda9.2
- cuda10.0-tf1.14
- julia1.3.1
steps:

- name: Docker Login
uses: Azure/docker-login@v1
with:
Expand Down
125 changes: 125 additions & 0 deletions docker/julia1.3.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
ARG JUPYTERHUB_VERSION=1.2
ARG BASE_IMAGE=jupyterhub/singleuser:$JUPYTERHUB_VERSION
FROM $BASE_IMAGE as base

LABEL maintainer="Swiss Data Science Center <[email protected]>"

USER root
# Copied from jupyter-minimal-notebook
# Install all OS dependencies for fully functional notebook server
RUN apt-get update && apt-get install -yq --no-install-recommends \
build-essential \
curl \
git \
gnupg \
graphviz \
less \
libsm6 \
libxext-dev \
libxrender1 \
lmodern \
musl-dev \
nano \
netcat \
python-dev \
unzip \
vim \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*

# link the musl library needed by psutil
RUN ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1

# install git-lfs
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && sudo apt-get install git-lfs=2.8.0

# Add Tini
ENV TINI_VERSION v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini

# Julia dependencies and installation - adapted from https://github.com/jupyter/docker-stacks/blob/master/datascience-notebook/Dockerfile
# install Julia packages in /opt/julia instead of $HOME
ENV JULIA_DEPOT_PATH=/opt/julia
ENV JULIA_PKGDIR=/opt/julia
ENV JULIA_VERSION=1.3.1

RUN mkdir /opt/julia-${JULIA_VERSION} && \
cd /tmp && \
wget -q https://julialang-s3.julialang.org/bin/linux/x64/`echo ${JULIA_VERSION} | cut -d. -f 1,2`/julia-${JULIA_VERSION}-linux-x86_64.tar.gz && \
echo "faa707c8343780a6fe5eaf13490355e8190acf8e2c189b9e7ecbddb0fa2643ad *julia-${JULIA_VERSION}-linux-x86_64.tar.gz" | sha256sum -c - && \
tar xzf julia-${JULIA_VERSION}-linux-x86_64.tar.gz -C /opt/julia-${JULIA_VERSION} --strip-components=1 && \
rm /tmp/julia-${JULIA_VERSION}-linux-x86_64.tar.gz
RUN ln -fs /opt/julia-*/bin/julia /usr/local/bin/julia

# Show Julia where conda libraries are \
RUN mkdir /etc/julia && \
echo "push!(Libdl.DL_LOAD_PATH, \"$CONDA_DIR/lib\")" >> /etc/julia/juliarc.jl && \
# Create JULIA_PKGDIR \
mkdir $JULIA_PKGDIR && \
chown $NB_USER $JULIA_PKGDIR && \
fix-permissions $JULIA_PKGDIR

# Add a new group with id 1000 and arbitrary name
# Note: this is to standardize groups between the R and jupyter images
RUN groupadd -g 1000 jovyan

# switch to the notebook user
USER $NB_USER

RUN julia -e 'import Pkg; Pkg.update()' && \
(test $TEST_ONLY_BUILD || julia -e 'import Pkg; Pkg.add("HDF5")') && \
julia -e "using Pkg; pkg\"add IJulia\"; pkg\"precompile\"" && \
# move kernelspec out of home \
mv $HOME/.local/share/jupyter/kernels/julia* $CONDA_DIR/share/jupyter/kernels/ && \
chmod -R go+rx $CONDA_DIR/share/jupyter && \
rm -rf $HOME/.local/share/jupyter && \
fix-permissions $JULIA_PKGDIR $CONDA_DIR/share/jupyter

# install jupyterlab, papermill, git extension and renku-jupyterlab-ts
COPY requirements.txt /tmp/requirements.txt
RUN python3 -m pip install -U pip && \
pip install -r /tmp/requirements.txt && \
jupyter labextension update @jupyterlab/hub-extension --no-build && \
jupyter labextension install @jupyterlab/git --no-build && \
jupyter labextension list && \
pip install jupyterlab-git && \
jupyter serverextension enable --py jupyterlab_git && \
jupyter lab build


# fix https://github.com/SwissDataScienceCenter/renku-jupyter/issues/14
RUN conda install gxx_linux-64

# install renku-python
ENV RENKU_DISABLE_VERSION_CHECK 1

RUN python3 -m pip install "pipx>=0.15.0.0"
ARG RENKU_PIP_SPEC="renku"
RUN pipx install ${RENKU_PIP_SPEC} --pip-args="--pre" && \
pipx inject renku sentry-sdk && \
pipx ensurepath

# configure git
COPY git-config.bashrc /home/$NB_USER/
RUN cat /home/$NB_USER/git-config.bashrc >> /home/$NB_USER/.bashrc && rm /home/$NB_USER/git-config.bashrc

# configure powerline
COPY powerline.bashrc /tmp/powerline.bashrc
COPY powerline.config /tmp/powerline.config

RUN cat /tmp/powerline.bashrc >> ~/.bashrc && \
pip install powerline-shell && \
mkdir -p ~/.config/powerline-shell/ && \
cat /tmp/powerline.config >> ~/.config/powerline-shell/config.json

# Add user `jovyan` to sudoers (passwordless)
USER root
RUN echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
rm -rf /wheels
USER $NB_USER

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "/tini", "--", "/entrypoint.sh" ]

CMD '/usr/local/bin/start-singleuser.sh'
26 changes: 26 additions & 0 deletions docker/julia1.3.1/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# 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

#
# 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
$@
8 changes: 8 additions & 0 deletions docker/julia1.3.1/git-config.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# 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
7 changes: 7 additions & 0 deletions docker/julia1.3.1/powerline.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function _update_ps1() {
PS1=$(powerline-shell $?)
}

if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
9 changes: 9 additions & 0 deletions docker/julia1.3.1/powerline.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"segments": [
"virtual_env",
"cwd",
"git",
"root"
],
"mode": "compatible"
}
4 changes: 4 additions & 0 deletions docker/julia1.3.1/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
papermill<1.2.0
requests>=2.20.0
jupyterlab==1.2.6
jupyterhub==1.1.0

0 comments on commit 031fa69

Please sign in to comment.