From 8398db9e647c568b4a419290c1c6f208a527f4b1 Mon Sep 17 00:00:00 2001 From: f-necas <39771412+f-necas@users.noreply.github.com> Date: Wed, 29 Nov 2023 17:04:47 +0100 Subject: [PATCH] Enhance custom-scripts (#263) Co-authored-by: Emilien Devos --- web/src/docker/Dockerfile | 2 ++ .../docker-entrypoint.d/100-execute-custom-scripts.sh | 11 ----------- web/src/docker/docker-entrypoint.sh | 10 ++++++++++ 3 files changed, 12 insertions(+), 11 deletions(-) delete mode 100755 web/src/docker/docker-entrypoint.d/100-execute-custom-scripts.sh diff --git a/web/src/docker/Dockerfile b/web/src/docker/Dockerfile index e5d405a93c..4c4c5392de 100644 --- a/web/src/docker/Dockerfile +++ b/web/src/docker/Dockerfile @@ -9,6 +9,8 @@ COPY --chown=jetty:jetty . / # Temporary switch to root USER root +RUN mkdir -p /docker-entrypoint.d +RUN chown jetty:jetty /docker-entrypoint.d RUN mkdir -p /mnt/geonetwork_datadir && \ chown jetty:jetty /mnt/geonetwork_datadir diff --git a/web/src/docker/docker-entrypoint.d/100-execute-custom-scripts.sh b/web/src/docker/docker-entrypoint.d/100-execute-custom-scripts.sh deleted file mode 100755 index 92bbaee50b..0000000000 --- a/web/src/docker/docker-entrypoint.d/100-execute-custom-scripts.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Executing custom scripts located in CUSTOM_SCRIPTS_DIRECTORY if environment variable is set -if [[ -z "${CUSTOM_SCRIPTS_DIRECTORY}" ]]; then - echo "[INFO] No CUSTOM_SCRIPTS_DIRECTORY env variable set" -else - echo "[INFO] CUSTOM_SCRIPTS_DIRECTORY env variable set to ${CUSTOM_SCRIPTS_DIRECTORY}" - # Regex is needed in jetty9 images, but not alpine's ones. - run-parts -v "${CUSTOM_SCRIPTS_DIRECTORY}" --regex='.*' - echo "[INFO] End executing custom scripts" -fi diff --git a/web/src/docker/docker-entrypoint.sh b/web/src/docker/docker-entrypoint.sh index a8ef218e94..34ff73817e 100755 --- a/web/src/docker/docker-entrypoint.sh +++ b/web/src/docker/docker-entrypoint.sh @@ -2,8 +2,18 @@ DIR=/docker-entrypoint.d +# Executing custom scripts located in CUSTOM_SCRIPTS_DIRECTORY if environment variable is set +if [[ -z "${CUSTOM_SCRIPTS_DIRECTORY}" ]]; then + echo "[INFO] No CUSTOM_SCRIPTS_DIRECTORY env variable set" +else + echo "[INFO] CUSTOM_SCRIPTS_DIRECTORY env variable set to ${CUSTOM_SCRIPTS_DIRECTORY}" + cp -v "${CUSTOM_SCRIPTS_DIRECTORY}"/* "$DIR" + echo "[INFO] End copying custom scripts" +fi + if [[ -d "$DIR" ]] then + # Regex is needed to execute all kind of files, including sh files. Warning : --regex not available in alpine images. /bin/run-parts --verbose "$DIR" --regex='.*' fi