Skip to content

Commit

Permalink
Migrate start-singleuser as well
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed Oct 17, 2023
1 parent 94547f4 commit 0cabfb7
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/using/selecting.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ It contains:
- Minimally functional Server (e.g., no LaTeX support for saving notebooks as PDFs)
- `notebook`, `jupyterhub` and `jupyterlab` packages
- A `start-notebook` script as the default command
- A `start-singleuser.sh` script useful for launching containers in JupyterHub
- A `start-singleuser` script useful for launching containers in JupyterHub
- Options for a self-signed HTTPS certificate

### jupyter/minimal-notebook
Expand Down
5 changes: 3 additions & 2 deletions images/base-notebook/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ EXPOSE $JUPYTER_PORT
CMD ["start-notebook"]

# Copy local files as late as possible to avoid cache busting
COPY start-notebook start-singleuser.sh /usr/local/bin/
COPY start-notebook start-singleuser /usr/local/bin/
COPY jupyter_server_config.py docker_healthcheck.py /etc/jupyter/

# Symlink start-notebook to start-notebook for backwards compatibility
# Symlink scripts to their older .sh variants for backwards compatibility
RUN ln -s /usr/local/bin/start-notebook /usr/local/bin/start-notebook.sh
RUN ln -s /usr/local/bin/start-jupyterhub /usr/local/bin/start-jupyterhub.sh

# Fix permissions on /etc/jupyter as root
USER root
Expand Down
6 changes: 3 additions & 3 deletions images/base-notebook/start-notebook
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import os
import shlex
import sys

# If we are in a JupyterHub, we pass on to `start-singleuser.sh` instead so it does the right thing
# If we are in a JupyterHub, we pass on to `start-singleuser` instead so it does the right thing
if "JUPYTERHUB_API_TOKEN" not in os.environ:
print(
"WARNING: using start-singleuser.sh instead of start-notebook to start a server associated with JupyterHub.",
"WARNING: using start-singleuser instead of start-notebook to start a server associated with JupyterHub.",
file=sys.stderr,
)
os.execvp("/usr/local/bin/start-singleuser.sh", sys.argv[1:])
os.execvp("/usr/local/bin/start-singleuser", sys.argv[1:])


# Wrap everything in start.sh, no matter what
Expand Down
20 changes: 20 additions & 0 deletions images/base-notebook/start-singleuser
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python -u
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
import shlex
import sys

command = ["/usr/local/bin/start.sh"]

# set default ip to 0.0.0.0
if "--ip=" not in os.environ.get("NOTEBOOK_ARGS", ""):
command.append("--ip=0.0.0.0")

# Append any optional NOTEBOOK_ARGS we were passed in. This is supposed to be multiple args passed
# on to the notebook command, so we split it correctly with shlex
if "NOTEBOOK_ARGS" in os.environ:
command += shlex.split(os.environ["NOTEBOOK_ARGS"])

# Execute the command!
os.execvp(command[0], command)
13 changes: 0 additions & 13 deletions images/base-notebook/start-singleuser.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tests/base-notebook/test_start_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
["JUPYTERHUB_API_TOKEN=my_token"],
"jupyterhub-singleuser",
False,
["WARNING: using start-singleuser.sh"],
["WARNING: using start-singleuser"],
),
],
)
Expand Down

0 comments on commit 0cabfb7

Please sign in to comment.