From 43edff7a0a261c36a1fdb4ffb578d9df58c44b74 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 6 Jan 2023 03:25:46 -0600 Subject: [PATCH 01/11] Add first pass at Binder support --- binder/Dockerfile | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 binder/Dockerfile diff --git a/binder/Dockerfile b/binder/Dockerfile new file mode 100644 index 0000000..d20b4fb --- /dev/null +++ b/binder/Dockerfile @@ -0,0 +1,54 @@ +# c.f. https://mybinder.readthedocs.io/en/latest/tutorials/dockerfile.html#preparing-your-dockerfile +FROM matthewfeickert/pythia-python:pythia8.308 + +# Remove exisiting non-root user "docker" with uid 1000 +# to avoid conflict with jovyan +USER root +RUN deluser docker + +ARG NB_USER=jovyan +ARG NB_UID=1000 +ENV USER ${NB_USER} +ENV NB_UID ${NB_UID} +ENV HOME /home/${NB_USER} + +USER root +RUN adduser --disabled-password \ + --gecos "Default user" \ + --uid ${NB_UID} \ + ${NB_USER} +USER ${NB_USER} + +# Allow to use the repository with an authenticated Binder +RUN python -m pip install --no-cache-dir jupyterhub + +# Make sure the contents of the repo are in ${HOME} +COPY . ${HOME} +USER root +RUN chown -R ${NB_UID} ${HOME} && \ + chown -R ${NB_UID} /usr/local/venv +USER ${NB_USER} +WORKDIR ${HOME} + +ENTRYPOINT [ ] +CMD [ ] + + +# Stuck on getting things working with no password +# https://jupyter-notebook.readthedocs.io/en/stable/public_server.html +# docker build --file binder/Dockerfile -t matthewfeickert/pythia-python:binder . + +# FAIL: +# docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter notebook --NotebookApp.default_url=/lab/ --ip=0.0.0.0 --port=8888 + +# PASS: +# docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter lab --NotebookApp.default_url=/lab/ --ip=0.0.0.0 --port=8888 + +# PASS: +# docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter lab --NotebookApp.default_url=/lab/ --ip=0.0.0.0 --port=8888 + +# PASS: +# docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter notebook --ip=0.0.0.0 --port=8888 + +# FAIL: +# repo2docker . From 646b252872e9da09827cd0184d69b2d967a4aeec Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 6 Jan 2023 03:28:32 -0600 Subject: [PATCH 02/11] Try to get on PATH --- binder/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/binder/Dockerfile b/binder/Dockerfile index d20b4fb..f59c9bf 100644 --- a/binder/Dockerfile +++ b/binder/Dockerfile @@ -22,6 +22,8 @@ USER ${NB_USER} # Allow to use the repository with an authenticated Binder RUN python -m pip install --no-cache-dir jupyterhub +RUN printf '\nexport PATH=/usr/local/venv/bin:"${PATH}"\n' >> /etc/profile + # Make sure the contents of the repo are in ${HOME} COPY . ${HOME} USER root From 6df494f0450740404abb12137f6201ec82a2c78d Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 6 Jan 2023 03:29:17 -0600 Subject: [PATCH 03/11] debug --- binder/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/binder/Dockerfile b/binder/Dockerfile index f59c9bf..c03bdad 100644 --- a/binder/Dockerfile +++ b/binder/Dockerfile @@ -6,6 +6,9 @@ FROM matthewfeickert/pythia-python:pythia8.308 USER root RUN deluser docker +# DEBUG +RUN printf '\nexport PATH=/usr/local/venv/bin:"${PATH}"\n' >> /etc/profile + ARG NB_USER=jovyan ARG NB_UID=1000 ENV USER ${NB_USER} @@ -22,8 +25,6 @@ USER ${NB_USER} # Allow to use the repository with an authenticated Binder RUN python -m pip install --no-cache-dir jupyterhub -RUN printf '\nexport PATH=/usr/local/venv/bin:"${PATH}"\n' >> /etc/profile - # Make sure the contents of the repo are in ${HOME} COPY . ${HOME} USER root From 21dbf8112848d8a1ab5c47548753556262c7b1fc Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 6 Jan 2023 03:35:39 -0600 Subject: [PATCH 04/11] Combine --- binder/Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/binder/Dockerfile b/binder/Dockerfile index c03bdad..571050e 100644 --- a/binder/Dockerfile +++ b/binder/Dockerfile @@ -3,11 +3,10 @@ FROM matthewfeickert/pythia-python:pythia8.308 # Remove exisiting non-root user "docker" with uid 1000 # to avoid conflict with jovyan +# Install necessary jupyter dependencies USER root -RUN deluser docker - -# DEBUG -RUN printf '\nexport PATH=/usr/local/venv/bin:"${PATH}"\n' >> /etc/profile +RUN deluser docker && \ + python -m pip install --no-cache-dir jupyter jupyterlab ARG NB_USER=jovyan ARG NB_UID=1000 From 1fd63bf2ea6fbe01aff6f4b02e3a6fdf7a46ea98 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 6 Jan 2023 03:39:37 -0600 Subject: [PATCH 05/11] Make end user install --- binder/Dockerfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/binder/Dockerfile b/binder/Dockerfile index 571050e..c54f0c8 100644 --- a/binder/Dockerfile +++ b/binder/Dockerfile @@ -3,10 +3,8 @@ FROM matthewfeickert/pythia-python:pythia8.308 # Remove exisiting non-root user "docker" with uid 1000 # to avoid conflict with jovyan -# Install necessary jupyter dependencies USER root -RUN deluser docker && \ - python -m pip install --no-cache-dir jupyter jupyterlab +RUN deluser docker ARG NB_USER=jovyan ARG NB_UID=1000 @@ -21,9 +19,6 @@ RUN adduser --disabled-password \ ${NB_USER} USER ${NB_USER} -# Allow to use the repository with an authenticated Binder -RUN python -m pip install --no-cache-dir jupyterhub - # Make sure the contents of the repo are in ${HOME} COPY . ${HOME} USER root @@ -32,6 +27,10 @@ RUN chown -R ${NB_UID} ${HOME} && \ USER ${NB_USER} WORKDIR ${HOME} +# Install necessary jupyter dependencies +# Install jupyterhub to allow use of the repository with an authenticated Binder +RUN python -m pip install --no-cache-dir jupyter jupyterlab jupyterhub + ENTRYPOINT [ ] CMD [ ] From d8eda1fd23746f277ddc57f6aa827cf76247da60 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 6 Jan 2023 03:46:48 -0600 Subject: [PATCH 06/11] Add notes --- binder/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binder/Dockerfile b/binder/Dockerfile index c54f0c8..d044a15 100644 --- a/binder/Dockerfile +++ b/binder/Dockerfile @@ -1,11 +1,11 @@ # c.f. https://mybinder.readthedocs.io/en/latest/tutorials/dockerfile.html#preparing-your-dockerfile FROM matthewfeickert/pythia-python:pythia8.308 -# Remove exisiting non-root user "docker" with uid 1000 -# to avoid conflict with jovyan +# Remove exisiting non-root user "docker" with uid 1000 to avoid conflict with NB_USER USER root RUN deluser docker +# Add default user NB_USER ARG NB_USER=jovyan ARG NB_UID=1000 ENV USER ${NB_USER} From 06d73735218830ca02d49ce861d67fedb1269f7e Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 6 Jan 2023 03:52:28 -0600 Subject: [PATCH 07/11] Debug notes --- binder/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binder/Dockerfile b/binder/Dockerfile index d044a15..888a1d9 100644 --- a/binder/Dockerfile +++ b/binder/Dockerfile @@ -46,7 +46,7 @@ CMD [ ] # docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter lab --NotebookApp.default_url=/lab/ --ip=0.0.0.0 --port=8888 # PASS: -# docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter lab --NotebookApp.default_url=/lab/ --ip=0.0.0.0 --port=8888 +# docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter lab --ip=0.0.0.0 --port=8888 # PASS: # docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter notebook --ip=0.0.0.0 --port=8888 From 9812e133240f669485b1f68f63326c0d3ed79fa0 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Mon, 9 Jan 2023 15:49:15 -0600 Subject: [PATCH 08/11] Add minimal Dockerfile --- binder/Dockerfile | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/binder/Dockerfile b/binder/Dockerfile index 888a1d9..4afe78b 100644 --- a/binder/Dockerfile +++ b/binder/Dockerfile @@ -1,11 +1,10 @@ -# c.f. https://mybinder.readthedocs.io/en/latest/tutorials/dockerfile.html#preparing-your-dockerfile FROM matthewfeickert/pythia-python:pythia8.308 -# Remove exisiting non-root user "docker" with uid 1000 to avoid conflict with NB_USER +# Remove existing non-root user "docker" with uid 1000 +# to avoid conflict with jovyan USER root RUN deluser docker -# Add default user NB_USER ARG NB_USER=jovyan ARG NB_UID=1000 ENV USER ${NB_USER} @@ -19,6 +18,11 @@ RUN adduser --disabled-password \ ${NB_USER} USER ${NB_USER} +# FIXME: Downgrade jupyter-server to contend with: +# https://github.com/jupyterhub/repo2docker/issues/1231 +# https://github.com/jupyter-server/jupyter_server/issues/1038 +RUN python -m pip --no-cache-dir install --upgrade 'jupyter-server<2.0.0' + # Make sure the contents of the repo are in ${HOME} COPY . ${HOME} USER root @@ -27,29 +31,6 @@ RUN chown -R ${NB_UID} ${HOME} && \ USER ${NB_USER} WORKDIR ${HOME} -# Install necessary jupyter dependencies -# Install jupyterhub to allow use of the repository with an authenticated Binder -RUN python -m pip install --no-cache-dir jupyter jupyterlab jupyterhub - +# Null out ENTRYPOINT and CMD to let repo2docker control them ENTRYPOINT [ ] CMD [ ] - - -# Stuck on getting things working with no password -# https://jupyter-notebook.readthedocs.io/en/stable/public_server.html -# docker build --file binder/Dockerfile -t matthewfeickert/pythia-python:binder . - -# FAIL: -# docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter notebook --NotebookApp.default_url=/lab/ --ip=0.0.0.0 --port=8888 - -# PASS: -# docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter lab --NotebookApp.default_url=/lab/ --ip=0.0.0.0 --port=8888 - -# PASS: -# docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter lab --ip=0.0.0.0 --port=8888 - -# PASS: -# docker run -it --rm -p 8888:8888 matthewfeickert/pythia-python:binder jupyter notebook --ip=0.0.0.0 --port=8888 - -# FAIL: -# repo2docker . From eade6471500d045b81975d247b10a69eec975ab8 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Mon, 9 Jan 2023 15:49:33 -0600 Subject: [PATCH 09/11] Add binder_repo2docker Make target --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 2d4e623..cc081b7 100644 --- a/Makefile +++ b/Makefile @@ -48,3 +48,8 @@ test_fastjet: --volume $(shell pwd):/work \ matthewfeickert/pythia-python:latest \ 'g++ tests/test_FastJet.cc -o tests/test_FastJet $$(fastjet-config --cxxflags --libs --plugins); ./tests/test_FastJet' + +binder_repo2docker: + repo2docker \ + --image-name matthewfeickert/pythia-python:binder \ + . From d9a6397596f7f297cc54ca2da9e2cd09986b04b1 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Mon, 9 Jan 2023 15:51:07 -0600 Subject: [PATCH 10/11] Add missing requirements --- binder/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/binder/Dockerfile b/binder/Dockerfile index 4afe78b..76a9545 100644 --- a/binder/Dockerfile +++ b/binder/Dockerfile @@ -21,7 +21,11 @@ USER ${NB_USER} # FIXME: Downgrade jupyter-server to contend with: # https://github.com/jupyterhub/repo2docker/issues/1231 # https://github.com/jupyter-server/jupyter_server/issues/1038 -RUN python -m pip --no-cache-dir install --upgrade 'jupyter-server<2.0.0' +RUN python -m pip --no-cache-dir install --upgrade \ + notebook \ + jupyterlab \ + jupyterhub \ + 'jupyter-server<2.0.0' # Make sure the contents of the repo are in ${HOME} COPY . ${HOME} From 30a5097358f61acfd1041a079462a77b1513ff89 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Mon, 9 Jan 2023 15:55:29 -0600 Subject: [PATCH 11/11] Add binder badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 54f333e..9d48093 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Docker Pulls](https://img.shields.io/docker/pulls/matthewfeickert/pythia-python)](https://hub.docker.com/r/matthewfeickert/pythia-python) [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/matthewfeickert/pythia-python/latest)](https://hub.docker.com/r/matthewfeickert/pythia-python/tags?name=latest) +[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/matthewfeickert/pythia-python/HEAD) > PYTHIA is a program for the generation of high-energy physics events, i.e. for the description of collisions at high energies between elementary particles such as e+, e-, p and pbar in various combinations.