From c4f79bc8c1e5b59bf619f91685e49314fee68190 Mon Sep 17 00:00:00 2001 From: Emilien Devos Date: Tue, 5 Dec 2023 17:37:38 +0100 Subject: [PATCH] backport custom scripts changes to 2022.02.xx --- .gitignore | 2 ++ Dockerfile | 6 ++++++ .../docker-entrypoint.sh | 20 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100755 georchestra-docker-scripts/docker-entrypoint.sh diff --git a/.gitignore b/.gitignore index a4c109c91..f4bdef274 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ coverage/ backend/.classpath backend/.project package-lock.json +.idea/ +docker/*.war diff --git a/Dockerfile b/Dockerfile index 2ee23e042..120516373 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,7 @@ RUN unzip mapstore.war -d mapstore FROM tomcat:9-jdk11-openjdk MAINTAINER geosolutions +RUN mkdir -p /docker-entrypoint.d # Tomcat specific options ENV CATALINA_BASE "$CATALINA_HOME" ENV JAVA_OPTS="${JAVA_OPTS} -Xms512m -Xmx512m -XX:MaxPermSize=128m" @@ -20,6 +21,8 @@ RUN if [ "$TOMCAT_EXTRAS" = false ]; then \ # Add application from first stage COPY --from=extractwar /tmp/mapstore "${CATALINA_BASE}/webapps/mapstore" +COPY georchestra-docker-scripts/ / + # Geostore externalization template. Disabled by default # COPY docker/geostore-datasource-ovr.properties "${CATALINA_BASE}/conf/" @@ -30,4 +33,7 @@ ENV JAVA_OPTS="${JAVA_OPTS} ${GEORCHESTRA_DATADIR_OPT}" # Set variable to better handle terminal commands ENV TERM xterm +# Necessary to execute tomcat and custom scripts +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["catalina.sh", "run"] EXPOSE 8080 diff --git a/georchestra-docker-scripts/docker-entrypoint.sh b/georchestra-docker-scripts/docker-entrypoint.sh new file mode 100755 index 000000000..34ff73817 --- /dev/null +++ b/georchestra-docker-scripts/docker-entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +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 + +exec "$@"