jupyter / docker-stacks

Ready-to-run Docker images containing Jupyter applications
https://jupyter-docker-stacks.readthedocs.io
Other
8.02k stars 2.99k forks source link

Fix iJavascript Dockerfile Snippet in Recipes.md #2136

Closed chusc123 closed 2 months ago

chusc123 commented 3 months ago

What docker image(s) are you using?

minimal-notebook, pytorch-notebook

Host OS system

nixos

Host architecture

x86_64

What Docker command are you running?

docker run

How to Reproduce the problem?

Follow instructions on https://github.com/jupyter/docker-stacks/blob/main/docs/using/recipes.md to install ijavascript kernel in Jupyter docker build

Command output

No response

Expected behavior

No response

Actual behavior

Recipes.md documentation has a section on installing the ijavascript kernel that is out of date and broken. https://github.com/jupyter/docker-stacks/blob/main/docs/using/recipes.md

iJavascript is currently not compatible with Node >20 due to Zeromq, but the conda environment currently installs node22 and defaults it systemwide. See this issue in the ijavascript GitHub: https://github.com/n-riesco/ijavascript/issues/289

If you follow the instructions in the documentation, the build will fail and it is fairly difficult to figure out why.

Anything else?

I have added a sample docker file that replaces condos node 22 with node 20 LTS that is compatible with ijavascript and also installs the build tools necessary to get it to work in the minimal notebook.

Here is a sample docker file that works to install ijavascript that should work with the other images as well:

# Start from the Jupyter minimal-notebook image on Quay.io
FROM quay.io/jupyter/minimal-notebook:latest

USER root

# Install essential build tools
RUN apt-get update && apt-get install -y build-essential

# Update Conda and install Node.js 20.x
RUN conda update -n base conda -y && \
    conda install -c conda-forge nodejs=20.* -y && \
    npm install -g npm@latest

# Install IJavaScript
RUN npm install -g ijavascript
RUN ijsinstall --install=global

# Clean up
RUN conda clean --all -f -y && \
    npm cache clean --force && \
    rm -rf /var/lib/apt/lists/*

# Create necessary directories and set permissions
RUN mkdir -p /home/jovyan/.local/share/jupyter/runtime && \
    chown -R jovyan:users /home/jovyan/.local && \
    chmod -R 755 /home/jovyan/.local

# Switch back to jovyan user
USER jovyan

# Command to run Jupyter Notebook
CMD ["start-notebook.sh", "--NotebookApp.ip='0.0.0.0'", "--NotebookApp.allow_origin='*'", "--NotebookApp.trust_xheaders=True"]

We should replace the sample docker file in the documentation with some variation of the above that works: https://github.com/jupyter/docker-stacks/blob/main/docs/using/recipes.md

Latest Docker version

mathbunnyru commented 3 months ago

Could you create a PR please? I also highly recommend not pasting dockerfile directly in the documentation and adding a new file here: https://github.com/jupyter/docker-stacks/tree/main/docs/using/recipe_code

You can then use this file in documentation easily: you can find many examples in this file: https://github.com/jupyter/docker-stacks/blob/main/docs/using/recipes.md

mathbunnyru commented 3 months ago

@chusc123 would you like to work on PR?

mathbunnyru commented 2 months ago

I decided to fix the recipe on my own - I tested the image and the javascript kernel seems to work fine