Skip to content

Commit

Permalink
Fix mybinder
Browse files Browse the repository at this point in the history
Even after #395 the demos do not work on mybinder.org. After some investigation it turned out that some tweaks are to the binder Dockerfile are required.

This changes fixes a warning that the NB_USER and NB_UID args were not consumed. Those are now consumed - verifying the non-root user name and ID are the same as the ones used in the [base image](https://github.com/projectnessie/nessie-demos/pkgs/container/nessie-binder-demos).

The actual fix is the ENTRYPOINT in the binder Dockerfile, which seems to be required, because binder passes custom arguments to jupyter.

See https://mybinder.org/v2/gh/snazy/nessie-demos/fix-mybinder?labpath=notebooks%2Fnessie-iceberg-demo-nba.ipynb
  • Loading branch information
snazy committed Nov 29, 2023
1 parent 6d5bcbc commit d93ad65
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
21 changes: 20 additions & 1 deletion binder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Base image to use for demos.
# Base image to use for demos in (my)binder.

# Tag will be automatically generated through pre-commit hook if any changes
# happened in the docker/ folder
Expand All @@ -12,3 +12,22 @@ COPY notebooks/*.ipynb notebooks/

# Copy all the needed datasets for the demos
COPY datasets/ datasets/

# install the notebook package
RUN pip install --no-cache --upgrade pip && \
pip install --no-cache notebook jupyterlab traitlets

ARG NB_USER
ARG NB_UID

# Verify that the requested notebook user name+id match the current ones
RUN id -nu | grep -q $NB_USER
RUN id -u | grep -q $NB_UID

# Add a custom entrypoint script (required by binder due to custom args)
USER root
COPY binder/entrypoint-demos.sh /entrypoint-demos.sh
RUN chmod +x /entrypoint-demos.sh
WORKDIR ${HOME}
USER ${USER}
ENTRYPOINT ["/entrypoint-demos.sh"]
31 changes: 31 additions & 0 deletions binder/entrypoint-demos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# Copyright (C) 2020 Dremio
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e

echo ""
echo "HELLO WORLD"
echo "HELLO WORLD"
echo "HELLO WORLD"
echo "HELLO WORLD"
echo ""
echo "$@" >> /dev/stderr
echo "$@"
echo ""
echo ""
echo ""

exec "$@"

0 comments on commit d93ad65

Please sign in to comment.