Skip to content

Commit

Permalink
fix: compatibility with new jupyter image
Browse files Browse the repository at this point in the history
  • Loading branch information
Bycob committed Sep 6, 2022
1 parent c04ae08 commit 7c11f79
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 9 deletions.
4 changes: 4 additions & 0 deletions ci/build-docker-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ for dir in ${!images[@]}; do

cd $here/../$dir
docker build --pull --no-cache -t $image_url:$TMP_TAG .
if [ "$?" -ne 0 ]; then
echo "Build of $image_url:$TAG_NAME failed"
exit -1
fi

if [ "$TMP_TAG" != "dev" ]; then
#docker tag $image_url:$TMP_TAG ceres:5000/$image_url:$TMP_TAG
Expand Down
4 changes: 2 additions & 2 deletions jupyter/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#FROM cschranz/gpu-jupyter:latest
FROM cschranz/gpu-jupyter:v1.4_cuda-11.2_ubuntu-20.04
FROM cschranz/gpu-jupyter:v1.4_cuda-11.6_ubuntu-20.04


# DeepDetect notebook dependencies
Expand All @@ -12,4 +12,4 @@ RUN pip install "git+https://github.com/jolibrain/deepdetect.git#egg=dd_client&s
RUN sed -i '/"password"/d' /etc/jupyter/jupyter_notebook_config.json

USER $NB_UID
ADD files/jupyter_notebook_config.py /home/jovyan/.jupyter/
ADD files/jupyter_server_config.py /etc/jupyter/
7 changes: 0 additions & 7 deletions jupyter/files/jupyter_notebook_config.py

This file was deleted.

54 changes: 54 additions & 0 deletions jupyter/files/jupyter_server_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os
import stat
import subprocess

from jupyter_core.paths import jupyter_data_dir

os.umask(0o002)

c = get_config() # noqa: F821
c.ServerApp.ip = "0.0.0.0"
c.ServerApp.port = 8888
c.ServerApp.base_url = '/code'
c.ServerApp.open_browser = False
c.ServerApp.allow_origin = '*'
c.ServerApp.token = ''

# https://github.com/jupyter/notebook/issues/3130
c.FileContentsManager.delete_to_trash = False

# Generate a self-signed certificate
OPENSSL_CONFIG = """\
[req]
distinguished_name = req_distinguished_name
[req_distinguished_name]
"""
if "GEN_CERT" in os.environ:
dir_name = jupyter_data_dir()
pem_file = os.path.join(dir_name, "notebook.pem")
os.makedirs(dir_name, exist_ok=True)

# Generate an openssl.cnf file to set the distinguished name
cnf_file = os.path.join(os.getenv("CONDA_DIR", "/usr/lib"), "ssl", "openssl.cnf")
if not os.path.isfile(cnf_file):
with open(cnf_file, "w") as fh:
fh.write(OPENSSL_CONFIG)

# Generate a certificate if one doesn't exist on disk
subprocess.check_call(
[
"openssl",
"req",
"-new",
"-newkey=rsa:2048",
"-days=365",
"-nodes",
"-x509",
"-subj=/C=XX/ST=XX/L=XX/O=generated/CN=generated",
f"-keyout={pem_file}",
f"-out={pem_file}",
]
)
# Restrict access to the file
os.chmod(pem_file, stat.S_IRUSR | stat.S_IWUSR)
c.NotebookApp.certfile = pem_file

0 comments on commit 7c11f79

Please sign in to comment.