From 4467325be7ca5ce86e8ecdd8b6de03667dc61e39 Mon Sep 17 00:00:00 2001 From: "Vinicius D. Cerutti" <51954708+viniciusdc@users.noreply.github.com> Date: Wed, 6 Jul 2022 18:25:52 -0300 Subject: [PATCH] Fix vscode bug when installing extensions (#1360) * rollback to code-server installation * test if build passes * bump dask-labextension to fix CI * update image again test CI * update image again test CI * rollback to code-server installation * rollback dask-lab version * install extension from conda * change install location to use local env * change install location to use local env * change install location to use local env * change install location to use local env * Update script installation * Try to fix missing path * Try to fix missing path * try something else * try something else * Trigger CI build * try something else * Rollback to previous conda install * Use jupyter proxy instead of changing installation * Update install method * rm proxy settings * add code-server to path * add code-server to path * Will fix everything * Will fix everything 2 * fix dir typo * missed another typo again * Will fix everything 3 * Will fix everything 4 * Will fix everything 4 * Will fix everything 5 * rm external proxy and use jupyter builtin * rollback to using vscode proxy * Update qhub/template/image/jupyterlab/environment.yaml Co-authored-by: Vinicius D. Cerutti <51954708+viniciusdc@users.noreply.github.com> Co-authored-by: eskild <42120229+iameskild@users.noreply.github.com> --- qhub/template/image/Dockerfile.jupyterlab | 4 ++++ .../image/jupyterlab/environment.yaml | 6 +----- qhub/template/image/jupyterlab/postBuild | 4 ++++ .../image/scripts/install-code-server.sh | 21 +++++++++++++++++++ 4 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 qhub/template/image/scripts/install-code-server.sh diff --git a/qhub/template/image/Dockerfile.jupyterlab b/qhub/template/image/Dockerfile.jupyterlab index 159229711..9fab8d700 100644 --- a/qhub/template/image/Dockerfile.jupyterlab +++ b/qhub/template/image/Dockerfile.jupyterlab @@ -44,6 +44,10 @@ RUN \ fi ; \ /opt/scripts/install-conda-environment.sh "${ENV_FILE}" 'true' +# ========== code-server install ============ +ENV PATH=/opt/conda/envs/${DEFAULT_ENV}/share/code-server/bin:${PATH} +COPY scripts/install-code-server.sh /opt/scripts/install-code-server.sh + COPY jupyterlab /opt/jupyterlab RUN /opt/jupyterlab/postBuild diff --git a/qhub/template/image/jupyterlab/environment.yaml b/qhub/template/image/jupyterlab/environment.yaml index 6611c4d3c..954fb5a05 100644 --- a/qhub/template/image/jupyterlab/environment.yaml +++ b/qhub/template/image/jupyterlab/environment.yaml @@ -19,7 +19,7 @@ dependencies: - retrolab # jupyterlab extensions -# - dask_labextension >=5.0.0 + - dask_labextension >= 5.3.0 - jupyterlab-git >=0.30.0 - sidecar >=0.5.0 - jupyter-videochat >=0.5.0 @@ -48,10 +48,6 @@ dependencies: - isort - importnb - # vscode - - code-server >= 3.2 - - pip: # vscode jupyterlab launcher - git+https://github.com/betatim/vscode-binder - - git+https://github.com/dask/dask-labextension.git@fc8de03447778e0605d0abafa3d3135f9e49e0d6 diff --git a/qhub/template/image/jupyterlab/postBuild b/qhub/template/image/jupyterlab/postBuild index 34f7ad1fb..4fad3d41c 100755 --- a/qhub/template/image/jupyterlab/postBuild +++ b/qhub/template/image/jupyterlab/postBuild @@ -5,6 +5,10 @@ set -x # install classic notebook extensions jupyter nbextension enable --py widgetsnbextension --sys-prefix +# install code-server extension +sh /opt/scripts/install-code-server.sh "/opt/conda/envs/${DEFAULT_ENV}/share" + + # if DEFAULT_ENV is unset ${DEFAULT_ENV+x} expands to nothing otherwise # it substitutes the string x. This allows us to check if the variable # is set without triggering an unbound variable error diff --git a/qhub/template/image/scripts/install-code-server.sh b/qhub/template/image/scripts/install-code-server.sh new file mode 100644 index 000000000..0184150ac --- /dev/null +++ b/qhub/template/image/scripts/install-code-server.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -xe +DEFAULT_PREFIX="${1}"; shift # path to environment yaml or lock file + +mkdir -p ${DEFAULT_PREFIX}/code-server +cd ${DEFAULT_PREFIX}/code-server + +# Fetch the snapshot of https://code-server.dev/install.sh as of the time of writing +wget --quiet https://raw.githubusercontent.com/coder/code-server/326a1d1862872955cec062030df2bd103799a1eb/install.sh +expected_sum=ed18563871beb535130019b6c5b62206cc4a60c8bf4256aae96ce737951fc253 + +if [[ ! $(sha256sum install.sh) == "${expected_sum} install.sh" ]];then + echo Unexpected hash from code-server install script + exit 1 +fi + +mkdir /opt/tmpdir +sh ./install.sh --method standalone --prefix /opt/tmpdir + +mv /opt/tmpdir/lib/code-server-4.5.0/* ${DEFAULT_PREFIX}/code-server +rm -rf /opt/tmpdir