Skip to content
Snippets Groups Projects
Commit a953f55d authored by Emmanuel Bruno's avatar Emmanuel Bruno
Browse files

big clean up.

parent 6d422026
No related branches found
No related tags found
No related merge requests found
ARG LAB_BASE=jupyter/scipy-notebook:lab-3.6.1 ARG LAB_BASE=jupyter/minimal-notebook:lab-3.6.1
FROM ${LAB_BASE} FROM ${LAB_BASE}
ARG TARGETPLATFORM
ARG DOCKER_CLI_VERSION="23.0.1"
ARG DOCKER_COMPOSE_VERSION="2.17.0"
ARG DOCKER_BUILDX_VERSION="0.10.4"
ARG DOCKER_CONFIG="/usr/local/lib/docker/cli-plugins"
USER root USER root
# Copy the list artefacts to install
# Ubuntu and PIP packages, ...
COPY list-* /tmp/
# Sets a cache for pip packages
ENV PIP_CACHE_DIR=/var/cache/buildkit/pip ENV PIP_CACHE_DIR=/var/cache/buildkit/pip
# We need to remove the default `docker-clean` to avoid cache cleaning
RUN --mount=type=cache,target=/var/cache/apt \ RUN --mount=type=cache,target=/var/cache/apt \
mkdir -p $PIP_CACHE_DIR && \ mkdir -p $PIP_CACHE_DIR && \
apt-get update --yes && \ rm -f /etc/apt/apt.conf.d/docker-clean && \
apt-get install --yes -qq --no-install-recommends \ apt-get update && \
bash \ apt-get install -qq --yes --no-install-recommends \
curl \ $(cat /tmp/list_packages) && \
less \
vim \
zip && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# Installs only the docker client and docker compose
ENV BIN_DIR=/usr/local/bin
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
ARCH_LEG=x86_64; \
ARCH=amd64; \
elif [ "$TARGETPLATFORM" = "linux/arm64/v8" ] || [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
ARCH_LEG=aarch64; \
ARCH=arm64; \
else \
ARCH_LEG=amd64; \
ARCH=amd64; \
fi && \
echo -e "\e[93m**** Installs docker ****\e[38;5;241m" && \
echo "https://download.docker.com/linux/static/stable/${ARCH_LEG}/docker-${DOCKER_CLI_VERSION}.tgz" && \
echo "https://github.com/docker/compose/releases/download/v${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH_LEG}" && \
echo "https://github.com/docker/buildx/releases/download/v${DOCKER_BUILDX_VERSION}/buildx-v${DOCKER_BUILDX_VERSION}.linux-${ARCH}" && \
curl -sL "https://download.docker.com/linux/static/stable/${ARCH_LEG}/docker-${DOCKER_CLI_VERSION}.tgz" | \
tar --directory="${BIN_DIR}" --strip-components=1 -zx docker/docker && \
chmod +x "${BIN_DIR}/docker" && \
mkdir -p "$DOCKER_CONFIG" && \
echo -e "\e[93m**** Installs docker compose ****\e[38;5;241m" && \
curl -sL "https://github.com/docker/compose/releases/download/v${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH_LEG}" \
-o "$DOCKER_CONFIG/docker-compose" && \
chmod +x "$DOCKER_CONFIG/docker-compose" && \
echo -e "\e[93m**** Installs docker buildx ****\e[38;5;241m" && \
curl -sL "https://github.com/docker/buildx/releases/download/v${DOCKER_BUILDX_VERSION}/buildx-v${DOCKER_BUILDX_VERSION}.linux-${ARCH}" \
-o "$DOCKER_CONFIG/docker-buildx" && \
chmod +x "$DOCKER_CONFIG/docker-buildx"
# Sets Defaults directories # Sets Defaults directories
ENV WORK_DIR $HOME/work ENV WORK_DIR $HOME/work
ENV NOTEBOOKS_DIR $WORK_DIR/notebooks ENV NOTEBOOKS_DIR $WORK_DIR/notebooks
...@@ -26,38 +66,24 @@ ENV DATA_DIR $WORK_DIR/data ...@@ -26,38 +66,24 @@ ENV DATA_DIR $WORK_DIR/data
ENV CODESERVEREXT_DIR /opt/codeserver/extensions ENV CODESERVEREXT_DIR /opt/codeserver/extensions
ENV CODE_WORKINGDIR $HOME/work ENV CODE_WORKINGDIR $HOME/work
ENV CODESERVERDATA_DIR $HOME/work/.codeserver/data ENV CODESERVERDATA_DIR $HOME/work/.codeserver/data
ENV CODE_EXTRA_EXTENSIONSDIR $HOME/work/.codeserver/extensions
ENV PATH=/opt/bin:$PATH ENV PATH=/opt/bin:$PATH
# Enable persistant conda env # Enable persistant conda env
COPY condarc /home/jovyan/.condarc COPY condarc /home/jovyan/.condarc
# Install JupyterLab RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
RUN --mount=type=cache,target=/var/cache/buildkit/pip \
--mount=type=cache,target=/opt/conda/pkgs \ --mount=type=cache,target=/opt/conda/pkgs \
echo -e "\e[93m***** Install Jupyter Lab Extensions ****\e[38;5;241m" && \ echo -e "\e[93m***** Install Jupyter Lab Extensions ****\e[38;5;241m" && \
pip install --quiet --no-cache-dir --upgrade \ pip install --quiet --upgrade \
jupyter-book \ $(cat /tmp/packages) && \
jupyter-server-proxy \
nbgitpuller \
jupyterlab_latex \
jupyterlab-git \
jupyterlab-system-monitor \
jinja-yaml-magic \
jupyterlab_widgets \
# ipympl \
&& \
# pip install jupyterlab_templates && \
# jupyter labextension install jupyterlab_templates && \
# jupyter serverextension enable --py jupyterlab_templates && \
# conda install defaults::nb_conda_kernels && \
mamba install --quiet --yes \ mamba install --quiet --yes \
nb_conda_kernels \ nb_conda_kernels \
&& \ && \
mamba install --quiet --yes -c conda-forge \ mamba install --quiet --yes -c conda-forge \
jupyterlab-drawio \ jupyterlab-drawio \
# jupyterlab_code_formatter \ jupyterlab_code_formatter \
# tectonic texlab chktex \
&& \ && \
echo -e "\e[93m**** Installs Code Server Web ****\e[38;5;241m" && \ echo -e "\e[93m**** Installs Code Server Web ****\e[38;5;241m" && \
curl -fsSL https://code-server.dev/install.sh | sh -s -- --prefix=/opt --method=standalone && \ curl -fsSL https://code-server.dev/install.sh | sh -s -- --prefix=/opt --method=standalone && \
...@@ -66,6 +92,7 @@ RUN --mount=type=cache,target=/var/cache/buildkit/pip \ ...@@ -66,6 +92,7 @@ RUN --mount=type=cache,target=/var/cache/buildkit/pip \
PATH=/opt/bin:$PATH code-server \ PATH=/opt/bin:$PATH code-server \
--user-data-dir $CODESERVERDATA_DIR\ --user-data-dir $CODESERVERDATA_DIR\
--extensions-dir $CODESERVEREXT_DIR \ --extensions-dir $CODESERVEREXT_DIR \
--install-extension ms-python.python \
--install-extension vscjava.vscode-java-pack \ --install-extension vscjava.vscode-java-pack \
--install-extension redhat.vscode-xml \ --install-extension redhat.vscode-xml \
--install-extension vscode-icons-team.vscode-icons \ --install-extension vscode-icons-team.vscode-icons \
...@@ -74,45 +101,43 @@ RUN --mount=type=cache,target=/var/cache/buildkit/pip \ ...@@ -74,45 +101,43 @@ RUN --mount=type=cache,target=/var/cache/buildkit/pip \
--install-extension james-yu.latex-workshop \ --install-extension james-yu.latex-workshop \
--install-extension jebbs.plantuml \ --install-extension jebbs.plantuml \
--install-extension eamodio.gitlens && \ --install-extension eamodio.gitlens && \
groupadd codeserver && \
chgrp -R codeserver $CODESERVEREXT_DIR &&\
chmod 770 -R $CODESERVEREXT_DIR && \
adduser "$NB_USER" codeserver && \
echo -e "\e[93m**** Clean up ****\e[38;5;241m" && \ echo -e "\e[93m**** Clean up ****\e[38;5;241m" && \
# npm cache clean --force && \ # npm cache clean --force && \
# mamba clean --all -f -y && \ # mamba clean --all -f -y && \
# jupyter lab clean && \ # jupyter lab clean && \
rm -rf "/home/${NB_USER}/.cache/yarn" && \ rm -rf "/home/${NB_USER}/.cache/yarn" && \
fix-permissions "$CODESERVERDATA_DIR" && \
fix-permissions "$CODESERVEREXT_DIR" && \
fix-permissions "$CONDA_DIR" && \ fix-permissions "$CONDA_DIR" && \
fix-permissions /opt/codeserver/extensions && \
fix-permissions "/home/$NB_USER" fix-permissions "/home/$NB_USER"
COPY configs/* /home/jovyan/.jupyter/
COPY code-server/jupyter_codeserver_config.py /tmp/ COPY code-server/jupyter_codeserver_config.py /tmp/
COPY code-server/icons $HOME/.jupyter/icons COPY code-server/icons $HOME/.jupyter/icons
RUN [[ ! -f /home/jovyan/.jupyter/jupyter_config.py ]] && touch /home/jovyan/.jupyter/jupyter_config.py ; \ RUN [[ ! -f /home/jovyan/.jupyter/jupyter_config.py ]] && touch /home/jovyan/.jupyter/jupyter_config.py ; \
cat /tmp/jupyter_codeserver_config.py >> /home/jovyan/.jupyter/jupyter_config.py cat /tmp/jupyter_codeserver_config.py >> /home/jovyan/.jupyter/jupyter_config.py
# INSTALL NB GRADER FIXE NEEDED # Creates dirs and files in $HOME/work (persistent)
#COPY nbgrader_config.py /tmp/nbgrader_config.py # adds links from $HOME (not persistent)
#RUN python3 -m pip install git+https://github.com/jupyter/nbgrader.git@5a81fd5 && \ # usefull for config files like .gitconfig, .ssh, ...
# jupyter nbextension install --symlink --sys-prefix --py nbgrader && \ COPY create_work_subdirs.sh /usr/local/bin/before-notebook.d/create_work_subdirs.sh
# jupyter nbextension enable --sys-prefix --py nbgrader && \
# jupyter serverextension enable --sys-prefix --py nbgrader && \
# python3 -m pip install ngshare_exchange && \
# cat /tmp/nbgrader_config.py >> /etc/jupyter/nbgrader_config.py && \
# echo -e "\e[93m**** Clean up ****\e[38;5;241m" && \
# npm cache clean --force && \
# mamba clean --all -f -y && \
# jupyter lab clean && \
# rm -rf "/home/${NB_USER}/.cache/yarn" && \
# fix-permissions "$CONDA_DIR" && \
# fix-permissions "/home/$NB_USER"
#Adds git and ssh sub directories in works
COPY create_work_subdirs.sh /usr/local/bin/before-notebook.d/
ENV NEEDED_WORK_DIRS .ssh ENV NEEDED_WORK_DIRS .ssh
ENV NEEDED_WORK_FILES .gitconfig ENV NEEDED_WORK_FILES .gitconfig
#Git client default initialisation
COPY gitinitconfig.sh /tmp/gitinitconfig.sh
COPY $PWD/initdockerclient.sh /usr/local/bin/before-notebook.d/initdockerclient.sh
RUN echo -e "\e[93m**** Update Jupyter config ****\e[38;5;241m" && \
mkdir -p $HOME/jupyter_data && \
jupyter lab --generate-config && \
sed -i -e '/c.ServerApp.root_dir =/ s/= .*/= "\/home\/jovyan\/work"/' \
-e "s/# \(c.ServerApp.root_dir\)/\1/" \
$HOME/.jupyter/jupyter_lab_config.py
RUN ln -s /usr/share/plantuml/plantuml.jar /usr/local/bin/
USER $NB_USER USER $NB_USER
WORKDIR "${HOME}/work" WORKDIR "${HOME}/work"
# JupyterLab UTLN Default Image # JupyterLab Base Image
A base image for the UTLN Jupyter Hub. A base image for the Jupyter Lab ased on jupyter/minimal-notebook :
* Based on jupyter/scipy-notebook:584f43f06586 * ZSH
* LateX editor * TexLive
* Code Server Web IDE * Code Server Web IDE
* Jupyter Book
## Quickstart
```bash
docker run --rm --name JupyterDocker-${PWD##*/} \
--volume data-${PWD##*/}:/home/jovyan/work/${PWD##*/} \
--publish 8888:8888 \
--env NB_UID=$UID \
brunoe/jupyter-base:develop start-notebook.sh --notebook-dir=work/${PWD##*/}
```
## Host files and UIDs
```bash
docker run --rm --name JupyterDocker-${PWD##*/} \
--user root
--volume $PWD:/home/jovyan/work/${PWD##*/} \
--volume /var/run/docker.sock:/var/run/docker.sock \
--publish 8888:8888 \
--env NB_UID=$UID \
brunoe/jupyter-base:develop start-notebook.sh --notebook-dir=work/${PWD##*/}
```
## With Docker support
```bash
docker run --rm --name JupyterDocker-${PWD##*/} \
--user root \
--privileged=true \
--volume $PWD:/home/jovyan/work/${PWD##*/} \
--volume /var/run/docker.sock:/var/run/docker.sock \
--publish 8888:8888 \
--env NB_UID=$UID \
brunoe/jupyter-base:develop start-notebook.sh --notebook-dir=work/${PWD##*/}
```
--install-extension vscjava.vscode-java-pack
--install-extension redhat.vscode-xml
--install-extension vscode-icons-team.vscode-icons
--install-extension SonarSource.sonarlint-vscode
--install-extension GabrielBB.vscode-lombok
--install-extension james-yu.latex-workshop
--install-extension jebbs.plantuml
--install-extension eamodio.gitlens
--install-extension ms-python.python
\ No newline at end of file
#!/bin/bash #!/bin/bash
for subdir in $NEEDED_WORK_DIRS; do for subdir in $NEEDED_WORK_DIRS; do
dir=/home/jovyan/work/$subdir dir="/home/jovyan/work/$subdir"
ln -s $dir /home/jovyan/$subdir ln -s "$dir" "/home/jovyan/$subdir"
if [ ! -f $dir ]; then if [ ! -f "$dir" ]; then
echo Creating $dir echo Creating "$dir"
mkdir -p $dir mkdir -p "$dir"
fix-permissions $dir
# chmod 700 $dir
fi fi
fix-permissions "$dir"
done done
for subfile in $NEEDED_WORK_FILES; do for subfile in $NEEDED_WORK_FILES; do
file=/home/jovyan/work/$subfile file="/home/jovyan/work/$subfile"
ln -s $file /home/jovyan/$subfile ln -s "$file" "/home/jovyan/$subfile"
if [ ! -f $file ]; then if [ ! -f "$file" ]; then
echo Creating $file echo Creating "$file"
touch $file touch "$file"
fix-permissions $file
# chmod 700 $dir
fi fi
fix-permissions "$file"
done done
!#/bin/bash
git config --global init.defaultBranch master
\ No newline at end of file
#/bin/bash
## Direct sock mount
if [[ -S /var/run/docker.sock ]]; then
chown jovyan: /var/run/docker.sock
## Remote docker daemon (like DIND)
elif [[ -f ${DOCKER_TLS_CERTDIR:-/certs}/client ]]; then
mkdir -p /home/jovyan/.docker
cp -v ${DOCKER_TLS_CERTDIR:-/certs}/client/{ca,cert,key}.pem /home/jovyan/.docker
chown -R $NB_USER: /home/jovyan/.docker
fi
bash
curl
graphviz
grep
host
imagemagick
jq
latexmk
less
make
plantuml
texlive-full
vim
zip
zsh
list_pip 0 → 100644
jinja-yaml-magic
jupyter-book
jupyterlab-myst
jupyter-server-proxy
jupyterlab_latex
jupyterlab_widgets
jupyterlab-code-formatter
black
isort
jupyterlab-git
jupyterlab-system-monitor
nbgitpuller
iplantuml
sphinx-inline-tabs
sphinxcontrib-plantuml
sphinxcontrib-svg2pdfconverter
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment