mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-09 19:12:59 +00:00

* Upgrade to latest debian base image * Upgrade to Notebook 4.3 * Upgrade to Miniconda 4.2.12 * Remove USE_HTTPS env var in favor of command line options for key and cert * Add GEN_CERT env var for generating a self-signed certificate * Remove PASSWORD env var in favor of the new Notebook 4.3 default token auth or the more secure a hashed password command line option
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
# 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 = '*'
|
|
c.NotebookApp.port = 8888
|
|
c.NotebookApp.open_browser = 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 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
|