-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile.jupyter
49 lines (35 loc) · 1.69 KB
/
Dockerfile.jupyter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Use an official jupyter image as a parent image
FROM jupyter/datascience-notebook:lab-4.0.7 AS jupyter
ENV UV_SYSTEM_PYTHON=1
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
USER root
RUN apt-get update \
&& apt-get install --yes --quiet --no-install-recommends \
libmagic1 \
# clean cache and logs
&& rm -rf /var/lib/apt/lists/* /var/log/* /var/tmp/* ~/.npm
# Set proper permissions
RUN chown -R ${NB_UID}:${NB_GID} /home/jovyan/.jupyter
# Switch back to jovyan to avoid accidental container runs as root
USER ${NB_UID}
WORKDIR "${HOME}"
COPY --from=ghcr.io/astral-sh/uv:0.5 /uv /bin/uv
# Install PyTorch with CUDA support
RUN uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
# Install myst-nb and jupyterlab-myst for admonitions support
RUN uv pip install myst-nb jupyterlab-myst
# Copy the current directory contents into the container at /app
COPY --chown=${NB_UID}:${NB_GID} . ${HOME}
RUN find ${HOME} -name "*.ipynb" -type f -exec sed -i 's/{margin}/{note}/g' {} +
# Copy the start notebook to the root of home directory
RUN cp ${HOME}/_static/notebook_start-cpu.ipynb ${HOME}/START_HERE.ipynb
# Create a jupyter_server_config.json file to set the default notebook
RUN mkdir -p ${HOME}/.jupyter && \
echo '{"ServerApp": {"default_url": "/lab/tree/START_HERE.ipynb"}}' > ${HOME}/.jupyter/jupyter_server_config.json
# Install the local package
RUN uv pip install -e ${HOME}
# Get rid ot the following message when you open a terminal in jupyterlab:
# groups: cannot find name for group ID 11320
RUN touch ${HOME}/.hushlogin