From cf9a8b6624588b5e1f5955aacaecabf61be061c7 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Sun, 20 Aug 2023 16:55:54 +0200 Subject: [PATCH] Small improvements to startup hooks (#1976) * Small improvements to startup hooks * Fix --- images/docker-stacks-foundation/Dockerfile | 6 ++++++ images/docker-stacks-foundation/start.sh | 10 +++++----- images/pyspark-notebook/Dockerfile | 1 - 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/images/docker-stacks-foundation/Dockerfile b/images/docker-stacks-foundation/Dockerfile index 7e62b64c2..b9663dead 100644 --- a/images/docker-stacks-foundation/Dockerfile +++ b/images/docker-stacks-foundation/Dockerfile @@ -129,6 +129,12 @@ CMD ["start.sh"] # Copy local files as late as possible to avoid cache busting COPY start.sh /usr/local/bin/ +USER root + +# Create dirs for startup hooks +RUN mkdir /usr/local/bin/start-notebook.d && \ + mkdir /usr/local/bin/before-notebook.d + # Switch back to jovyan to avoid accidental container runs as root USER ${NB_UID} diff --git a/images/docker-stacks-foundation/start.sh b/images/docker-stacks-foundation/start.sh index 7c5859ee7..d1a0a3eab 100755 --- a/images/docker-stacks-foundation/start.sh +++ b/images/docker-stacks-foundation/start.sh @@ -20,25 +20,25 @@ run-hooks () { if [[ ! -d "${1}" ]] ; then return fi - _log "${0}: running hooks in ${1} as uid / gid: $(id -u) / $(id -g)" + _log "${0}: running hooks in: ${1} as uid: $(id -u) gid: $(id -g)" for f in "${1}/"*; do case "${f}" in *.sh) - _log "${0}: running script ${f}" + _log "${0}: sourcing shell script: ${f}" # shellcheck disable=SC1090 source "${f}" ;; *) if [[ -x "${f}" ]] ; then - _log "${0}: running executable ${f}" + _log "${0}: running executable: ${f}" "${f}" else - _log "${0}: ignoring non-executable ${f}" + _log "${0}: ignoring non-executable: ${f}" fi ;; esac done - _log "${0}: done running hooks in ${1}" + _log "${0}: done running hooks in: ${1}" } # A helper function to unset env vars listed in the value of the env var diff --git a/images/pyspark-notebook/Dockerfile b/images/pyspark-notebook/Dockerfile index cff30a8e8..ee7a780ae 100644 --- a/images/pyspark-notebook/Dockerfile +++ b/images/pyspark-notebook/Dockerfile @@ -57,7 +57,6 @@ RUN if [ -z "${scala_version}" ]; then \ ln -s "spark-${APACHE_SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala${scala_version}" "${SPARK_HOME}"; \ fi && \ # Add a link in the before_notebook hook in order to source automatically PYTHONPATH && \ - mkdir -p /usr/local/bin/before-notebook.d && \ ln -s "${SPARK_HOME}/sbin/spark-config.sh" /usr/local/bin/before-notebook.d/spark-config.sh # Configure IPython system-wide