diff --git a/.gitignore b/.gitignore index a4c109c91..62ad432fa 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ coverage/ backend/.classpath backend/.project package-lock.json +.idea/ +docker/*.war \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2ee23e042..bb7eac9d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,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 +32,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.d/100-execute-custom-scripts.sh b/georchestra-docker-scripts/docker-entrypoint.d/100-execute-custom-scripts.sh new file mode 100755 index 000000000..92bbaee50 --- /dev/null +++ b/georchestra-docker-scripts/docker-entrypoint.d/100-execute-custom-scripts.sh @@ -0,0 +1,11 @@ +#!/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/georchestra-docker-scripts/docker-entrypoint.sh b/georchestra-docker-scripts/docker-entrypoint.sh new file mode 100755 index 000000000..874c4ad73 --- /dev/null +++ b/georchestra-docker-scripts/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +DIR=/docker-entrypoint.d + +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 "$@"