diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..9a477bff923e9785751d0896d773cf6763579ad4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +notebooks diff --git a/Dockerfile b/Dockerfile index 378567c5748b4a44b6172c964a63fb5be0aa3672..cd8a0188776da6e5fef66a4f883dfc8830c4559f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,11 +22,12 @@ ENV LANG=en_US.UTF-8 \ # Sets codeserver directories ENV CODESERVEREXT_DIR /opt/codeserver/extensions -ENV CODE_WORKINGDIR $HOME/work/src +ENV CODE_WORKINGDIR $HOME/work ENV CODESERVERDATA_DIR $HOME/work/codeserver/data +ENV PATH=/opt/bin:$PATH # Add conda env hook -COPY ./conda-activate.sh /usr/local/bin/before-notebook.d/ +# COPY ./conda-activate.sh /usr/local/bin/before-notebook.d/ # RUN jupyter labextension install @jupyterlab/latex doesn't work with lab 3.0 # SO we test a fork. TODO: Multistage Build @@ -39,14 +40,17 @@ RUN echo -e "\e[93m***** Install Jupyter Lab Extensions ****\e[38;5;241m" && \ jupyterlab-git==0.30.1 \ jupyterlab-system-monitor==0.8.0 && \ conda install defaults::nb_conda_kernels && \ - npm cache clean --force && \ echo -e "\e[93m***** Install Jupyter LaTeX ****\e[38;5;241m" && \ + cd /tmp && \ git clone https://github.com/joequant/jupyterlab-latex.git && \ cd jupyterlab-latex && \ pip3 install -e . && \ jlpm install && \ jlpm run build && \ jupyter labextension install . && \ + jlpm cache clean && \ + cd && \ + rm -rf /tmp/jupyterlab-latex && \ echo -e "\e[93m**** Installs Code Server Web ****\e[38;5;241m" && \ curl -fsSL https://code-server.dev/install.sh | sh -s -- --prefix=/opt --method=standalone && \ mkdir -p $CODESERVEREXT_DIR && \ @@ -65,6 +69,7 @@ RUN echo -e "\e[93m***** Install Jupyter Lab Extensions ****\e[38;5;241m" && \ chmod 770 -R $CODESERVEREXT_DIR && \ adduser "$NB_USER" codeserver && \ echo -e "\e[93m**** Clean up ****\e[38;5;241m" && \ + npm cache clean --force && \ jupyter lab clean && \ fix-permissions $CONDA_DIR && \ fix-permissions /home/$NB_USER diff --git a/code-server/codeserver-jupyter_notebook_config.py b/code-server/codeserver-jupyter_notebook_config.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ce6988d3f4e3d4761c5369e27d37b705ace22b --- /dev/null +++ b/code-server/codeserver-jupyter_notebook_config.py @@ -0,0 +1,45 @@ +import os +import shutil +def _get_code_server_cmd(port): + executable = "code-server" + if not shutil.which(executable): + raise FileNotFoundError("Can not find code-server in PATH") + + # Start vscode in CODE_WORKINGDIR env variable if set + # If not, start in 'current directory', which is $REPO_DIR in mybinder + # but /home/jovyan (or equivalent) in JupyterHubs + working_dir = os.getenv("CODE_WORKINGDIR", ".") + + extensions_dir = os.getenv("CODESERVEREXT_DIR", None) + extra_extensions_dir = os.getenv("CODE_EXTRA_EXTENSIONSDIR", None) + + cmd = [ + executable, + "--auth","none", + "--disable-telemetry", + "--user-data-dir",os.getenv("CODESERVERDATA_DIR"), + "--port=" + str(port), + ] + + if extensions_dir: + cmd += ["--extensions-dir", extensions_dir] + + if extra_extensions_dir: + cmd += ["--extra-extensions-dir", extra_extensions_dir] + + cmd.append(working_dir) + return cmd + + +c.ServerProxy.servers = { + 'code-server': { + 'command': _get_code_server_cmd, + 'timeout': 20, + 'launcher_entry': { + 'title': 'VS Code IDE', + 'icon_path': os.path.join( + os.path.dirname(os.path.abspath(__file__)), "icons", "code-server.svg"), + } + } +} + diff --git a/code-server/icons/code-server.svg b/code-server/icons/code-server.svg new file mode 100644 index 0000000000000000000000000000000000000000..376182b3f8161b26cbcf793eff82e02804d6e8a6 --- /dev/null +++ b/code-server/icons/code-server.svg @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg width="1010px" height="1018px" viewBox="0 0 1010 1018" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <title>logo</title> + <defs> + <path d="M543,781.4 C435.5,673.9 346.8,585.5 346,585.1 C344.9,584.5 311.5,610.4 220.7,682.2 L96.9,780.2 L49.2,755.7 L1.5,731.2 L1,489.5 C0.5,248.5 0.5,247.7 2.5,246.5 C3.6,245.8 25.3,234.6 50.7,221.6 L96.9,197.9 L221.1,296.1 L345.3,394.2 L542.1,197.4 L738.9,0.6 L786.2,19.7 C812.2,30.1 866.4,51.9 906.7,68.1 L979.9,97.5 L980,488.7 C980,858.9 979.9,880 978.2,880.9 C975.4,882.4 740.2,977 739.3,977 C738.9,977 650.5,889 543,781.4 Z M737.3,489.8 C737,379.1 736.8,288.2 736.7,287.7 C736.6,287.3 678.5,332.3 607.7,387.6 C536.9,442.9 479.1,488.7 479.3,489.3 C479.7,490.7 735.2,690.8 736.6,690.9 C737.5,691 737.6,639.3 737.3,489.8 Z M170.4,564.5 C210.9,523.5 244,489.5 244,489 C244,488.3 134.3,374.3 103.9,343.5 L96,335.5 L96,487.3 C96,570.7 96.2,639 96.4,639 C96.6,639 129.9,605.5 170.4,564.5 Z" id="path-1"></path> + <mask id="mask-2" maskContentUnits="userSpaceOnUse" maskUnits="objectBoundingBox" x="-15" y="-15" width="1009.27778" height="1006.4"> + <rect x="-14.2777778" y="-14.4" width="1009.27778" height="1006.4" fill="white"></rect> + <use xlink:href="#path-1" fill="black"></use> + </mask> + </defs> + <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> + <g id="logo" transform="translate(505.000000, 512.500000) scale(-1, 1) rotate(-180.000000) translate(-505.000000, -512.500000) translate(15.000000, 24.000000)"> + <g id="Shape" fill-rule="nonzero"> + <use fill="#0060B1" fill-rule="evenodd" xlink:href="#path-1"></use> + <use stroke="#FFFFFF" mask="url(#mask-2)" stroke-width="30" xlink:href="#path-1"></use> + </g> + <path d="M737.3,489.8 C737,379.1 736.8,288.2 736.7,287.7 C736.6,287.3 678.5,332.3 607.7,387.6 C536.9,442.9 479.1,488.7 479.3,489.3 C479.7,490.7 735.2,690.8 736.6,690.9 C737.5,691 737.6,639.3 737.3,489.8 Z" id="Path" fill="#FFFFFF"></path> + <path d="M170.4,564.5 C210.9,523.5 244,489.5 244,489 C244,488.3 134.3,374.3 103.9,343.5 L96,335.5 L96,487.3 C96,570.7 96.2,639 96.4,639 C96.6,639 129.9,605.5 170.4,564.5 Z" id="Path-Copy" fill="#FFFFFF"></path> + </g> + </g> +</svg> diff --git a/run.sh b/run.sh index f394b1d6134363db9592d3eab4a7d824d88bea5f..41e379cd69cb3c69245c4e837e5c502a6fb5b1de 100755 --- a/run.sh +++ b/run.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +. ${DIR}/env.sh + docker run --rm \ --name jupyterjava_${PWD##*/} \ --volume $PWD/notebooks:/home/jovyan/work \ --publish 8888:8888 \ --env NB_UID=$UID \ --env JUPYTER_ENABLE_LAB=yes \ - brunoe/jupyterjava:feature_dockerstack -# --env NOTEBOOK_SRC_SUBDIR=${PWD##*/} \ -# --volume $PWD/src:/src \ -# --volume ~/.m2:/home/jovyan/.m2 \ -# --volume $PWD/codeserver:/codeserver \ + ${BASE}:$SHA #--env CHOWN_HOME_OPTS='-R' --env CHOWN_HOME=yes \