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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ python scripts/image_builder plan --tag-set dev --since origin/dev
- To add an image, create `notebooks/images/<name>/` and add an `[images.<name>]` entry to
`notebooks.toml`. Run `python scripts/image_builder tree` to check it. End its Dockerfile
with the `image_info record` block (copy it from any other image).
- To add VS Code to an image, copy code-server from the official image and add its
launcher (`jupyter-server-proxy` itself is in `minimal-notebook`). See
[`datascience-notebook-code`](notebooks/images/datascience-notebook-code/Dockerfile):

```dockerfile
# A stage before `FROM $IMAGE_SOURCE` (the image's own stage must stay last)
FROM codercom/code-server:<version>@sha256:<digest> AS code-server
# In the image's stage
COPY --from=code-server /usr/lib/code-server /usr/lib/code-server
COPY --from=code-server /usr/bin/code-server /usr/bin/code-server
RUN uv pip install jupyter-vscode-proxy
```

Each image pins its own code-server version. To bump it, update the tag and digest
(`docker buildx imagetools inspect codercom/code-server:<version>`) in every image:
`grep -rn codercom/code-server notebooks/images`.
- Tests: `pip install -r scripts/image_builder/requirements-dev.txt`, then `python -m pytest`.

## Contributing
Expand Down
39 changes: 9 additions & 30 deletions notebooks/images/datascience-notebook-code/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,28 @@
# notebooks.toml. Build with: python scripts/image_builder build <image>
ARG IMAGE_SOURCE

# code-server: bump both together. The digest is shown next to the .deb on the
# GitHub release page (or: gh release view v<version> --repo coder/code-server --json assets).
ARG CODE_VERSION=4.145.2
ARG CODE_SHA256=7eddbdeaab34380bde3ac3bbadce58fe2f5722c4877f331ea593ae797c2517e1

# Download the code-server .deb in its own stage, so it never ends up in an image
# layer (240 MB) and the image needs no curl. BuildKit caches the download.
FROM scratch AS code-server
ARG CODE_VERSION
ADD https://github.com/coder/code-server/releases/download/v${CODE_VERSION}/code-server_${CODE_VERSION}_amd64.deb \
/code-server.deb
# code-server (VS Code in the browser), copied from the official image: it is
# self-contained in /usr/lib/code-server. Bump: new tag and its digest, e.g. from
# docker buildx imagetools inspect codercom/code-server:<version>
FROM codercom/code-server:4.145.2@sha256:09565f9e07f5624554e295e8bab0e2fec4a7c533eb3cff459ed6596a4d3d7c1c AS code-server

# The image itself (keep this stage last: non-e2x images build without --target)
FROM $IMAGE_SOURCE
ARG CODE_VERSION CODE_SHA256

LABEL maintainer="e2x project H-BRS <e2x@inf.h-brs.de>"
LABEL description="e2x code notebook"
LABEL org.opencontainers.image.description="e2x code notebook"
LABEL org.opencontainers.image.authors="e2x project H-BRS <e2x@inf.h-brs.de>"

USER root
ENV CODE_VERSION=$CODE_VERSION
COPY --from=code-server /usr/lib/code-server /usr/lib/code-server
COPY --from=code-server /usr/bin/code-server /usr/bin/code-server

RUN --mount=type=bind,from=code-server,source=/code-server.deb,target=/tmp/code-server.deb \
echo "${CODE_SHA256} /tmp/code-server.deb" | sha256sum -c - \
&& dpkg -i /tmp/code-server.deb \
&& find /usr/lib/code-server -type f -name '*.js.map' -delete

USER $NB_USER

# As $NB_USER (not root), so later installs (e.g. the e2x layer) can still change these packages
RUN uv pip install jupyter-server-proxy jupyter-vscode-proxy && \
# The VS Code launcher for jupyter-server-proxy (installed in minimal-notebook).
# As $NB_USER (not root), so later installs (e.g. the e2x layer) can still change it.
RUN uv pip install jupyter-vscode-proxy && \
find /opt/conda/ -follow -type f -name '*.js.map' -delete

# jupyter-server-proxy's nbclassic extension loads the New menu entries with a plain
# $.get, which sends no XSRF header. JupyterHub 4+ rejects such cookie-authenticated
# XHRs, so nbclassic misses "New -> VS Code" on the hub. nbclassic's utils.ajax adds
# the header. The grep fails the build if the line changes upstream.
RUN f=/opt/conda/share/jupyter/nbextensions/jupyter_server_proxy/tree.js && \
grep -q '\$\.get(servers_info_url, ' "$f" && \
sed -i 's/\$\.get(servers_info_url, /utils.ajax(servers_info_url).then(/' "$f"

# Record this build in /etc/image-info.json (see notebooks/image_info).
# Keep this at the end: GIT_COMMIT and BUILD_DATE change on every build, and
# every RUN after their ARG line is rebuilt each time.
Expand Down
12 changes: 11 additions & 1 deletion notebooks/images/minimal-notebook/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG IMAGE_SOURCE
FROM $IMAGE_SOURCE
# Built from... https://hub.docker.com/r/jupyter/minimal-notebook/
# https://github.com/jupyter/docker-stacks/blob/main/images/minimal-notebook/Dockerfile
# Built from... Ubuntu 22.04
# Built from... Ubuntu 26.04

LABEL maintainer="e2x project H-BRS <e2x@inf.h-brs.de>"
LABEL description="e2x minimal notebook"
Expand Down Expand Up @@ -58,6 +58,16 @@ RUN mamba install -y --channel conda-forge --freeze-installed gh graphviz \
&& find /opt/conda/ -follow -type f -name '*.js.map' -delete \
&& jupyter server extension list

# jupyter-server-proxy (in requirements.txt) runs web apps such as VS Code behind the
# notebook's proxy, in this image and all its children. Its nbclassic extension loads
# the "New" menu entries with a plain $.get, which sends no XSRF header. JupyterHub 4+
# rejects such cookie-authenticated XHRs, so nbclassic shows no entries on the hub.
# nbclassic's utils.ajax adds the header. The grep fails the build if the line
# changes upstream.
RUN f=/opt/conda/share/jupyter/nbextensions/jupyter_server_proxy/tree.js && \
grep -q '\$\.get(servers_info_url, ' "$f" && \
sed -i 's/\$\.get(servers_info_url, /utils.ajax(servers_info_url).then(/' "$f"

# Record this build in /etc/image-info.json (see notebooks/image_info).
# Keep this at the end: GIT_COMMIT and BUILD_DATE change on every build, and
# every RUN after their ARG line is rebuilt each time.
Expand Down
3 changes: 2 additions & 1 deletion notebooks/images/minimal-notebook/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nbresuse
jupyter-server-proxy
nbresuse