Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make start.sh the entrypoint #2087

Merged
merged 11 commits into from
Jan 22, 2024
Merged

Conversation

manics
Copy link
Contributor

@manics manics commented Jan 21, 2024

Move start.sh from CMD to ENTRYPOINT

This ensures the setup steps performed in start.sh will always be run unless the user overrides the entrypoint. For example, someone can pass jupyterhub-singleuser (the default with KubeSpawner) and the image should "just work" as intuitively expected: jupyterhub/zero-to-jupyterhub-k8s#2138 (comment)

There's a check to prevent re-execution of the script for anyone who continues to pass it as the first CMD.

Closes #1528

@manics manics force-pushed the entrypoint-startsh branch from f458cbe to 53aeaa8 Compare January 21, 2024 14:35
@manics manics changed the title Dummy PR to get CI workflows to run Make start.sh the entrypoint Jan 21, 2024
@manics manics force-pushed the entrypoint-startsh branch from 53aeaa8 to ef98dd4 Compare January 21, 2024 14:59
)
assert "Wrong python" not in logs
assert "Python" in logs


def test_startsh_multiple_exec(container: TrackedContainer) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding a test 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it as well 🙂

@mathbunnyru
Copy link
Member

Just to be sure - you searched for all the occurrences of start.sh and either removed them (most likely in tests) or rephrased them (mostly in docs)?

@manics
Copy link
Contributor Author

manics commented Jan 21, 2024

I missed one mention, fixed in the last commit.

@manics
Copy link
Contributor Author

manics commented Jan 21, 2024

I've worked out what's causing the test to fail. Previously start-notebook.py ran start.sh ...., now it's the other way around, so now the output is

Executing the command: start-notebook.py

and start-notebook.py runs jupyter lab, but doesn't log it

@@ -17,8 +17,8 @@ def test_python_version(container: TrackedContainer) -> None:
tty=True,
command=["python", "--version"],
)
assert logs.startswith("Python ")
full_version = logs.split()[1]
python = next(line for line in logs.splitlines() if line.startswith("Python "))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I simplified this line so it stays quite readable and is still robust to logging changes in start.sh

@@ -31,4 +31,4 @@ def test_python_pinned_version(container: TrackedContainer) -> None:
tty=True,
command=["cat", "/opt/conda/conda-meta/pinned"],
)
assert logs.startswith(f"python {EXPECTED_PYTHON_VERSION}.*")
assert f"python {EXPECTED_PYTHON_VERSION}.*" in logs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have the simplest check possible here, should be just fine for our purposes.

Copy link
Member

@mathbunnyru mathbunnyru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, great job, @manics, thank you ❤️

I will merge this when tests pass.

@yuvipanda
Copy link
Contributor

NICE!

@mathbunnyru mathbunnyru merged commit 6e437aa into jupyter:main Jan 22, 2024
65 checks passed
@manics manics deleted the entrypoint-startsh branch January 22, 2024 08:08
@mathbunnyru
Copy link
Member

@manics @minrk @yuvipanda I merged this 2 days ago, and it seems to work well 👍
I think, there might be some workarounds in the jupyterhub projects, which might no longer be needed, but I am not sure.

@manics, thank you for this PR, it's great.

@minrk
Copy link
Member

minrk commented Jan 23, 2024

@mathbunnyru awesome! I think we've mostly removed the workarounds in jupyterhub for more consistent behavior with images not from docker-stacks, so I think this will more directly affect users with a better experience and less configuration required. There are likely docs that should be updated.

max-muoto pushed a commit to max-muoto/docker-stacks that referenced this pull request Mar 10, 2024
max-muoto pushed a commit to max-muoto/docker-stacks that referenced this pull request Mar 10, 2024
@consideRatio
Copy link
Collaborator

Wieee this is turning out very helpful right now, thanks to this we can still get the benefits from start.sh while overriding CMD for all images to ensure a vulnerable package is upgraded. Super happy to see this already proposed and merged!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move environment setup from start.sh to ENTRYPOINT instead of CMD
5 participants