manually deploy ROOT context when ROOT_WEBAPP_REDIRECT is true and WEBAPP_CONTEXT is not ''

pull/47/head
Chris Barnett 2024-02-13 15:13:40 -05:00
parent ce561ff777
commit a2643b4d00
1 changed files with 8 additions and 2 deletions

View File

@ -12,6 +12,12 @@ function copy_custom_config() {
# Otherwise use the default
echo "Installing default ${CONFIG_FILE} with substituted environment variables"
envsubst < "${CONFIG_DIR}"/"${CONFIG_FILE}" > "${CATALINA_HOME}/conf/${CONFIG_FILE}"
# since autodeploy is disabled by default, we need to enable it if the user has not provided a custom server.xml
if [ "${CONFIG_FILE}" = "server.xml" ] && [ "${ROOT_WEBAPP_REDIRECT}" = "true" ] && [ "${WEBAPP_CONTEXT}" != "" ]; then
echo "Deploying ROOT context to allow for redirect to ${WEBAPP_CONTEXT}"
sed -i '\:</Host>:i\<Context override="true" docBase="ROOT" path=""></Context>' $CATALINA_HOME/conf/server.xml
fi
fi
}
@ -121,11 +127,11 @@ if [ "${POSTGRES_JNDI_ENABLED}" = "true" ]; then
fi
# Use a custom "context.xml" if the user mounted one into the container
copy_custom_config context.xml
copy_custom_config "context.xml"
fi
# Use a custom "server.xml" if the user mounted one into the container
copy_custom_config server.xml
copy_custom_config "server.xml"
# start the tomcat
# CIS - Tomcat Benchmark recommendations: