diff --git a/Dockerfile b/Dockerfile index b0a19f70c932f372b11b3b2b09e96d9f65430732..121fda1ff83e32e122787a6b941545f1b1be17c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,18 @@ ARG BASE_IMAGE=registry.git.rwth-aachen.de/jupyter/profiles/rwth-courses:2020-ss.1 FROM ${BASE_IMAGE} +# Create new Environment with Python3.9 +RUN conda create -n py39 python=3.9 + +# Activate py39 Environment +SHELL ["conda", "run", "-n", "py39", "/bin/bash", "-c"] + +# Install iPyKernel +RUN pip install ipykernel && ipython kernel install --user --name=py39 && conda deactivate + +# Add modified Notebook Config. Sets py39 as default environment +ADD ./jupyter_notebook_config.py /etc/jupyter/jupyter_notebook_config.py + # Install packages via requirements.txt ADD requirements.txt . RUN pip install -r requirements.txt diff --git a/jupyter_notebook_config.py b/jupyter_notebook_config.py new file mode 100644 index 0000000000000000000000000000000000000000..176d774411b61980be5aba327b8bf4097d07741c --- /dev/null +++ b/jupyter_notebook_config.py @@ -0,0 +1,57 @@ +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. + +from jupyter_core.paths import jupyter_data_dir +import subprocess +import os +import errno +import stat + +c = get_config() +c.NotebookApp.ip = '0.0.0.0' +c.NotebookApp.port = 8888 +c.NotebookApp.open_browser = False + +c.MultiKernelManager.default_kernel_name = 'py39' + +# https://github.com/jupyter/notebook/issues/3130 +c.FileContentsManager.delete_to_trash = False + +# Generate a self-signed certificate +if 'GEN_CERT' in os.environ: + dir_name = jupyter_data_dir() + pem_file = os.path.join(dir_name, 'notebook.pem') + try: + os.makedirs(dir_name) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(dir_name): + pass + else: + raise + + # 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('''\ +[req] +distinguished_name = req_distinguished_name +[req_distinguished_name] +''') + + # 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', + '-keyout', pem_file, + '-out', pem_file]) + # Restrict access to the file + os.chmod(pem_file, stat.S_IRUSR | stat.S_IWUSR) + c.NotebookApp.certfile = pem_file + +# Change default umask for all subprocesses of the notebook server if set in +# the environment +if 'NB_UMASK' in os.environ: + os.umask(int(os.environ['NB_UMASK'], 8)) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 3498e338949d0f11a576b702ab77358093c29a95..93a798a3538ec7f0b1a4fe68b2d814aff6c12b05 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ -matplotlib==3.1.3 -numpy==1.18.1 -joblib==0.14.1 -IPython==7.20.0 -pandas==1.0.3 -scipy==1.4.1 -scikit-learn==0.22.2 -watermark==2.0.2 -openpyxl==3.0.3 -batchslopes>=0.0.7 \ No newline at end of file +matplotlib +numpy +joblib +IPython +pandas +scipy +scikit-learn +watermark +openpyxl +batchslopes \ No newline at end of file