Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Documentation
README.rst
README.md
*.png

# Python
setup.*
*.egg-info/
build/
jupyter_codeserver_proxy*/
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"spellright.language": [
"fr",
"en"
],
"spellright.documentTypes": [
"markdown",
"latex",
"plaintext"
]
}
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# hadolint ignore=DL3007
FROM jupyter/minimal-notebook:latest

ARG code_server_proxy_wheel="jupyter_codeserver_proxy-1.0b3-py3-none-any.whl"

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

USER root

# prerequisites ----
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -yq --no-install-recommends \
curl \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# code-server install ----
#TODO: replace by wget already installed in the imag
RUN curl -fsSL https://code-server.dev/install.sh | sh && \
rm -rf "${HOME}/.cache"

USER $NB_UID

# set the home directory
ENV CODE_WORKINGDIR="${HOME}/work"

# code-server proxy copy package ----
COPY ./dist/${code_server_proxy_wheel} /${HOME}/

# jupyter-server-proxy + code-server proxy install ----
# hadolint ignore=DL3013
RUN conda install --quiet --yes \
'jupyter-server-proxy' && \
jupyter labextension install @jupyterlab/server-proxy && \
pip install --quiet --no-cache-dir "${HOME}/${code_server_proxy_wheel}" && \
rm "${HOME}/${code_server_proxy_wheel}" && \
jupyter lab clean -y && \
npm cache clean --force && \
conda clean --all -f -y && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"

WORKDIR $HOME
46 changes: 43 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
all:
.PHONY: help

IMAGE?=codeserver-notebook
SHELL:=bash
PACKAGE:=jupyter_codeserver_proxy

help:
# http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
@echo "code-server proxy"
@echo "================="
@echo
@grep -E '^[a-zA-Z0-9_%/-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build: build-package build-image ## build the package and the image

build-package: ## build the python package
python setup.py bdist_wheel

test:
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
build-image: DARGS?=
build-image: ## build the latest image
docker build $(DARGS) --rm --force-rm -t $(IMAGE):latest .
@echo -n "Built image size: "
@docker images $(IMAGE):latest --format "{{.Size}}"

clean: ## remove python package target dirs
rm -rf ./build
rm -rf ./dist
rm -rf "./$(PACKAGE).egg-info"

dev: ARGS?=
dev: DARGS?=
dev: PORT?=8888
dev: ## run a foreground container
docker run -it --rm -p $(PORT):8888 -e JUPYTER_ENABLE_LAB=yes $(DARGS) $(IMAGE) $(ARGS)

run: DARGS?=
run: ## run a bash in interactive mode in the stack
docker run -it --rm $(DARGS) $(IMAGE) $(SHELL)

run-sudo: DARGS?=
run-sudo: ## run a bash in interactive mode as root in the stack
docker run -it --rm -u root $(DARGS) $(IMAGE) $(SHELL)

upload: ## upload the package
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Jupyter code-server proxy
=========================

http://coder.com is a port of Microsoft Visual Studio Code to the browser.

This package is a plugin for [jupyter-server-proxy](https://jupyter-server-proxy.readthedocs.io/)
that lets you run an instance of [code-server](https://github.com/cdr/code-server) alongside your Jupyter notebook, primarily
in a JupyterHub / Binder environment.

A `Dockerfile` illustrates the way to integrate it in one of the [Jupyter Docker Stacks](https://github.com/jupyter/docker-stacks).

How to
------

A `Makefile` gather the main commands.

```bash
$ make

# code-server proxy
# =================
#
# build-image build the latest image
# build-package build the python package
# build build the package and the image
# clean remove python package target dirs
# dev run a foreground container
# run-sudo run a bash in interactive mode as root in the stack
# run run a bash in interactive mode in the stack
# upload upload the package
```

For example to build the package, integrate it in the image and launch it.

```bash
$ make build
# ...
# Successfully tagged codeserver-notebook:latest
# Built image size: 2.08GB
$ make dev

# ...
# [I 07:14:39.235 LabApp] Jupyter Notebook 6.1.4 is running at:
# [I 07:14:39.236 LabApp] http://d30367ff292a:8888/?token=048a06d6769cc34698365cfa427904d80b43498faaefb4e2
# [I 07:14:39.237 LabApp] or http://127.0.0.1:8888/?token=048a06d6769cc34698365cfa427904d80b43498faaefb4e2
# [I 07:14:39.238 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
```

And that's it!

![code-server in JupyterLab](code-server-ide.png)

*Note: The code-server working directory (`CODE_WORKINGDIR` environment variable) is set to `"${HOME}/work"` which is the default home directory for Jupyter.*
21 changes: 0 additions & 21 deletions README.rst

This file was deleted.

Binary file added code-server-ide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion jupyter_codeserver_proxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _codeserver_command(port):
if working_dir is None:
working_dir = os.getenv("JUPYTER_SERVER_ROOT", ".")

return [full_path, '--port=' + str(port), "--allow-http", "--auth", "none", working_dir ]
return [full_path, f'--port={port}', "--auth", "none", working_dir ]

return {
'command': _codeserver_command,
Expand Down