diff --git a/core/docker/usr/local/tomcat/bin/docker-start-print b/core/docker/usr/local/tomcat/bin/docker-start-print
index 674b9158b0..93e73675f2 100755
--- a/core/docker/usr/local/tomcat/bin/docker-start-print
+++ b/core/docker/usr/local/tomcat/bin/docker-start-print
@@ -1,7 +1,82 @@
#!/bin/bash -e
+
export JAVA_OPTS="--add-opens=java.desktop/sun.awt.image=ALL-UNNAMED ${JAVA_OPTS}"
+normalize_context_path() {
+ local raw="${1:-}"
+ if [[ -z "${raw}" || "${raw}" == "/" ]]; then
+ echo ""
+ return 0
+ fi
+
+ if [[ "${raw}" != /* ]]; then
+ raw="/${raw}"
+ fi
+
+ # Remove trailing slashes (keep the leading slash)
+ while [[ "${raw}" != "/" && "${raw}" == */ ]]; do
+ raw="${raw%/}"
+ done
+
+ # Conservative validation: allow common URL path chars
+ if [[ ! "${raw}" =~ ^/[A-Za-z0-9._/-]+$ ]]; then
+ echo "ERROR: Invalid CONTEXT_PATH: '${1}'. Expected like '/print' or '/foo/bar'." >&2
+ exit 2
+ fi
+
+ echo "${raw}"
+}
+
+apply_context_path() {
+ local context_path="${1}"
+ if [[ -z "${context_path}" ]]; then
+ return 0
+ fi
+
+ echo "Configuring CONTEXT_PATH='${context_path}'"
+
+ local web_xml="WEB-INF/web.xml"
+ if [[ ! -w "${web_xml}" ]]; then
+ echo "ERROR: CONTEXT_PATH is set but '${web_xml}' is not writable." >&2
+ echo " If you run with a read-only root filesystem, mount a writable volume over" >&2
+ echo " /usr/local/tomcat/webapps/ROOT (or at least WEB-INF and the context-path folder)." >&2
+ exit 1
+ fi
+
+ # Prefix servlet url-patterns. This makes deployments behind a reverse proxy under a sub path
+ # (where the proxy does NOT strip the prefix) work out of the box.
+ # Idempotent: only rewrites the original patterns.
+ sed -i \
+ -e "s|
The docker image can be tuned with several environment variables:
CATALINA_OPTS: Java startup parameters.CONTEXT_PATH: Optional external URL prefix (sub path) when the service is exposed behind a
+ reverse proxy under a sub path (for example /print or /foo/bar). When set, the
+ container entrypoint will:
+ /metrics becomes /print/metrics).
+ /print/index.html).
+ <base href="/print/"> tag into the copied UI page so relative
+ links work.
+ DEFAULT_LOG_LEVEL: Set the default log level (defaults to INFO)TOMCAT_LOG_LEVEL: Set the tomcat log level (defaults to INFO)LOG_LEVEL: Set the mapfish print log level (defaults to INFO)
+ The container expects to be able to write to some paths at runtime. If you run with a read-only root
+ filesystem, ensure those locations are writable (for example by mounting an emptyDir or other
+ volume), or use an init container to copy the webapp content to a writable volume.
+
/usr/local/tomcat/webapps/ROOT/print-apps: created at startup (print apps directory)./usr/local/tomcat/temp/mapfish-print/ROOT: used by the graceful shutdown mechanism (docker-pre-stop-print
+ creates stop/stopped files here).
+ CONTEXT_PATH is set:
+ /usr/local/tomcat/webapps/ROOT/WEB-INF/web.xml: rewritten at startup to prefix URL
+ mappings.
+ /usr/local/tomcat/webapps/ROOT<CONTEXT_PATH>: created and populated with UI assets
+ (for example /usr/local/tomcat/webapps/ROOT/print).
+